From 03809cfa0f0b2d57a9aa18b3c1fa92fc7d6ff097 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 7 Nov 2013 10:58:27 -0500 Subject: [PATCH] improve error reporting --- web/includes/database.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/web/includes/database.php b/web/includes/database.php index f597101de..3ff4c2f5e 100644 --- a/web/includes/database.php +++ b/web/includes/database.php @@ -112,7 +112,7 @@ function dbQuery( $sql, $params=NULL ) $result = $dbConn->query( $sql ); } } catch(PDOException $e) { - dbError( $sql . $e->getMessage() ); + Fatal( "SQL-ERR '".$e.getMessage()."', statement was '".$sql."'" ); } return( $result ); } @@ -120,8 +120,10 @@ function dbQuery( $sql, $params=NULL ) function dbFetchOne( $sql, $col=false, $params=NULL ) { $result = dbQuery( $sql, $params ); - if ( ! $result ) + if ( ! $result ) { + Fatal( "SQL-ERR dbFetchOne no result, statement was '".$sql."'" ); return false; + } if ( $result && $dbRow = $result->fetch( PDO::FETCH_ASSOC ) ) return( $col?$dbRow[$col]:$dbRow ); @@ -131,6 +133,10 @@ function dbFetchOne( $sql, $col=false, $params=NULL ) function dbFetchAll( $sql, $col=false ) { $result = dbQuery( $sql ); + if ( ! $result ) { + Fatal( "SQL-ERR dbFetchAll no result, statement was '".$sql."'" ); + return false; + } $dbRows = array(); while( $dbRow = $result->fetch( PDO::FETCH_ASSOC ) )