Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for getting database error #3207

Merged
merged 1 commit into from
Jul 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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