Skip to content

Commit

Permalink
Merge pull request #3207 from michalsn/db_errors
Browse files Browse the repository at this point in the history
Fix for getting database error
  • Loading branch information
lonnieezell authored Jul 4, 2020
2 parents f861629 + f5084da commit ea635b8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 20 deletions.
25 changes: 7 additions & 18 deletions system/Database/BaseConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -373,12 +373,12 @@ public function initialize()

$this->connectTime = microtime(true);

try
try
{
// Connect to the database and set the connection ID
$this->connID = $this->connect($this->pConnect);
}
catch (\Throwable $e)
}
catch (\Throwable $e)
{
log_message('error', 'Error connecting to the database: ' . $e->getMessage());
}
Expand All @@ -401,14 +401,14 @@ public function initialize()
}
}

try
try
{
// Try to connect
$this->connID = $this->connect($this->pConnect);
}
catch (\Throwable $e)
}
catch (\Throwable $e)
{
log_message('error', 'Error connecting to the database: '.$e->getMessage());
log_message('error', 'Error connecting to the database: ' . $e->getMessage());
}

// If a connection is made break the foreach loop
Expand Down Expand Up @@ -557,17 +557,6 @@ public function getPrefix(): string

//--------------------------------------------------------------------

/**
* Returns the last error encountered by this connection.
*
* @return mixed
*/
public function getError()
{
}

//--------------------------------------------------------------------

/**
* The name of the platform in use (MySQLi, mssql, etc)
*
Expand Down
2 changes: 1 addition & 1 deletion system/Database/ConnectionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public function getDatabase(): string;
*
* @return mixed
*/
public function getError();
public function error(): array;

//--------------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion system/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -1334,7 +1334,7 @@ public function errors(bool $forceDB = false)
}

// Still here? Grab the database-specific error, if any.
$error = $this->db->getError();
$error = $this->db->error();

return $error['message'] ?? null;
}
Expand Down

0 comments on commit ea635b8

Please sign in to comment.