Log the SQL for errors in wpsql_insert_id

If the query produces an error, log the query which produced the error
in addition to the insert statement which preceded it.  This helped me
track down an issue with a mis-named sequence from a bad
MySQL->PostgreSQL migration.

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
This commit is contained in:
Kevin Locke
2015-09-12 09:53:23 -07:00
parent b9479d4559
commit 2ab93ef3a4

View File

@ -183,7 +183,9 @@
elseif( PG4WP_DEBUG || PG4WP_ERROR_LOG)
{
$log = '['.microtime(true)."] wpsql_insert_id() was called with '$table' and '$ins_field'".
" and generated an error. The latest INSERT query was :\n'$lastq'\n";
" and returned the error:\n".pg_last_error().
"\nFor the query:\n".$sql.
"\nThe latest INSERT query was :\n'$lastq'\n";
error_log( $log, 3, PG4WP_LOG.'pg4wp_errors.log');
}
}