From 8c9b00fbc54a44f9303aeac46efe8f9e27c8b53e Mon Sep 17 00:00:00 2001 From: Andrew McMillan Date: Fri, 19 Mar 2010 18:29:12 -0700 Subject: [PATCH] Improved logging of failed queries. --- inc/AwlQuery.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/inc/AwlQuery.php b/inc/AwlQuery.php index b4192d19..3ac6ccde 100644 --- a/inc/AwlQuery.php +++ b/inc/AwlQuery.php @@ -504,12 +504,21 @@ class AwlQuery if ( ! $success ) { // query failed + if ( $c->dbg['print_query_errors'] ) { + printf( "\n=====================\n" ); + printf( "%s[%d] QF: %s\n", $file, $line, $this->errorstring); + printf( "%s\n", $this->querystring ); + foreach( $this->bound_parameters AS $k => $v ) { + printf( " '%s' \t=> '%s'\n", $k, $v ); + } + printf( ".....................\n" ); + } $this->errorstring = sprintf( 'SQL error "%s" - %s"', $this->error_info[0], (isset($this->error_info[2]) ? $this->error_info[2] : '')); $this->_log_query( $this->location, 'QF', $this->errorstring, $line, $file ); $this->_log_query( $this->location, 'QF', $this->querystring, $line, $file ); if ( isset($this->bound_parameters) && ! ( isset($c->dbg['querystring']) || isset($c->dbg['ALL']) ) ) { foreach( $this->bound_parameters AS $k => $v ) { - $this->_log_query( $this->location, 'QF', sprintf(' "%s" => "%s"', $k, $v), $line, $file ); + dbg_error_log( 'LOG-'.$this->location, ' Query: QF: "%s" => "%s"', $k, $v); } } }