Capturing SQL Notifications from Propel ORM
I have a large SQL function that I want to execute on a PostgreSQL database via PHP / Propel using a prepared statement:
$sql = "lots of SQL statements";
$statement = $propelPDO->prepare($sql);
$statement->execute();
In the SQL statements I am trying to execute, there are many calls to "raise information ..." and "raise warning ..." which display debug information. While executing SQL from the command line, I see these notifications that help me debug SQL:
psql -h hostname database username < lots_of_sql_statements.sql
My question is, is there a way to capture the information and warning messages raised in SQL from PHP so that I can log them for later analysis? I am running SQL on a lot of different records and it would be great to be able to log notifications instead of going to the command line every time to see debug information.
source to share
Ok if you are using actual Propel objects you can catch messages by catching PropelException
try {
$propelObject
->setSomething('foo')
->save()
;
} catch (PropelException $pe) {
someLoggingFunction($pe->getMessage());
}
Otherwise, you are just limited to PDO error handling functions:
source to share