Doctrine 1.x log all queries

To log all queries we need to use Event Listeners

class QueryDebuggerListener extends Doctrine_EventListener
    public function preStmtExecute(Doctrine_Event $event)
        $q = $event->getQuery();
        $params = $event->getParams();

        while (sizeof($params) > 0) {
            $param = array_shift($params); 

            if (!is_numeric($param)) {
                $param = sprintf("'%s'", $param);

            $q = substr_replace($q, $param, strpos($q, '?'), 1); 
$queryDbg = new QueryDebuggerListener();
$dbh = new PDO($dsn, $user, $password);
$conn = Doctrine_Manager::connection($dbh);

Restore #AWS RDS instance from a database snapshot by using AWS CLI

The AWS Command Line Interface is a unified tool to manage your AWS services.
I am using AWS RDS PostgreSQL for my application. I don’t need to run this application 24/7/365. So I have the ability to stop periodically my instances to save some money in my pocket. Nobody wants to do repeated tasks manually. So am I.
Below is the bash script which I use to restore db instance from a snapshot and wait till availability status:

aws rds restore-db-instance-from-db-snapshot --db-instance-identifier myDBinstanseName --db-snapshot-identifier myDBinstanseName-final-snapshot --db-instance-class db.t1.micro --no-multi-az
while [ `aws rds describe-db-instances --db-instance-identifier myDBinstanseName| python -c 'import json,sys;obj=json.load(sys.stdin);print obj["DBInstances"][0]["DBInstanceStatus"]'` != "available" ]; do sleep 10; done

Note: This script is part of bigger automation. So I don’t run it manually:)