I have a large SQL function that I want to execute on a PostgreSQL database via PHP/Propel using a prepared statement like so:
$sql = "lots of SQL statements";
$statement = $propelPDO->prepare($sql);
$statement->execute();
In the SQL statements I’m trying to execute, there are many calls to “raise info …” and “raise warning …” which show debugging information. Executing the SQL from the command line, I can see this notices which helps to debug the SQL:
psql -h hostname database username < lots_of_sql_statements.sql
My question: is there any way to capture the info and warning notices raised in the SQL from PHP so that I can log them for later analysis? I am running the SQL over a lot of different records and it would be great to be able to log the notices instead of having to go the command line for each individually to see the debugging info.
Well if you use the actual Propel objects you can catch messages by catching
PropelExceptionOtherwise you’re simply limited to the PDO error handling functions:
http://www.php.net/manual/en/pdo.error-handling.php