Skip to content

Commit

Permalink
ENH Various fixes for PHP 8.1 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
emteknetnz committed Apr 21, 2022
1 parent 7143861 commit 7a88f91
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/ORM/Connect/MySQLiConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace SilverStripe\ORM\Connect;

use mysqli;
use mysqli_sql_exception;
use mysqli_stmt;
use SilverStripe\Core\Config\Config;

Expand Down Expand Up @@ -63,7 +64,12 @@ public function prepareStatement($sql, &$success)
// Record last statement for error reporting
$statement = $this->dbConn->stmt_init();
$this->setLastStatement($statement);
$success = $statement->prepare($sql);
try {
$success = $statement->prepare($sql);
} catch (mysqli_sql_exception $e) {
$success = false;
$this->databaseError($e->getMessage(), E_USER_ERROR, $sql);
}
return $statement;
}

Expand Down

0 comments on commit 7a88f91

Please sign in to comment.