This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Fixing mysqli error message

Store error message and error number before calling mysqli_ping (which would clean errors)
  • Loading branch information...
obsidev committed Sep 27, 2012
1 parent aed408f commit 91cc43ae478a82def81482e493e47f580a33390c
Showing with 3 additions and 6 deletions.
  1. +3 −6 libraries/joomla/database/driver/mysqli.php
@@ -503,6 +503,9 @@ public function execute()
// If an error occurred handle it.
if (!$this->cursor)
{
+ $this->errorNum = (int) mysqli_errno($this->connection);
+ $this->errorMsg = (string) mysqli_error($this->connection) . ' SQL=' . $sql;
+
// Check if the server was disconnected.
if (!$this->connected())
{
@@ -515,9 +518,6 @@ public function execute()
// If connect fails, ignore that exception and throw the normal exception.
catch (RuntimeException $e)
{
- $this->errorNum = (int) mysqli_errno($this->connection);
- $this->errorMsg = (string) mysqli_error($this->connection) . ' SQL=' . $sql;
-
JLog::add(JText::sprintf('JLIB_DATABASE_QUERY_FAILED', $this->errorNum, $this->errorMsg), JLog::ERROR, 'databasequery');
throw new RuntimeException($this->errorMsg, $this->errorNum);
}
@@ -528,9 +528,6 @@ public function execute()
// The server was not disconnected.
else
{
- $this->errorNum = (int) mysqli_errno($this->connection);
- $this->errorMsg = (string) mysqli_error($this->connection) . ' SQL=' . $sql;
-
JLog::add(JText::sprintf('JLIB_DATABASE_QUERY_FAILED', $this->errorNum, $this->errorMsg), JLog::ERROR, 'databasequery');
throw new RuntimeException($this->errorMsg, $this->errorNum);
}

0 comments on commit 91cc43a

Please sign in to comment.