Skip to content

Commit

Permalink
Fixing mysqli error message
Browse files Browse the repository at this point in the history
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 91cc43a
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions libraries/joomla/database/driver/mysqli.php
Expand Up @@ -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())
{
Expand All @@ -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);
}
Expand All @@ -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);
}
Expand Down

0 comments on commit 91cc43a

Please sign in to comment.