From 28434a195d68ad8f3be75d2322a0e9b63ee44924 Mon Sep 17 00:00:00 2001 From: Sean Harvey Date: Mon, 10 May 2010 22:56:43 +0000 Subject: [PATCH] MINOR Better debugging in MSSQLDatabase::query() --- code/MSSQLDatabase.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/code/MSSQLDatabase.php b/code/MSSQLDatabase.php index e1ca91a..801dd41 100644 --- a/code/MSSQLDatabase.php +++ b/code/MSSQLDatabase.php @@ -213,20 +213,21 @@ class MSSQLDatabase extends SS_Database { if(isset($_REQUEST['showqueries'])) { $starttime = microtime(true); } - + if($this->mssql) { $handle = mssql_query($sql, $this->dbConn); } else { $handle = sqlsrv_query($this->dbConn, $sql); if($handle) $this->lastAffectedRows = sqlsrv_rows_affected($handle); } - + if(isset($_REQUEST['showqueries'])) { $endtime = round(microtime(true) - $starttime,4); Debug::message("\n$sql\n{$endtime}ms\n", false); } - - if(!$handle && $errorLevel) $this->databaseError("Couldn't run query: $sql", $errorLevel); + + $error = mssql_get_last_message(); + if(!$handle && $errorLevel) $this->databaseError("Couldn't run query ($error): $sql", $errorLevel); return new MSSQLQuery($this, $handle, $this->mssql); }