mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-20 09:30:49 +08:00
fix php8 compatibility
This commit is contained in:
@@ -97,6 +97,11 @@ class DB
|
||||
return $this->driver->escapeString($string);
|
||||
}
|
||||
|
||||
public function lastInsertId()
|
||||
{
|
||||
return $this->driver->lastInsertId();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ class DBMysqli implements DBInterface
|
||||
$mysqli = new mysqli($host, $username, $password, $database, $port);
|
||||
/* check connection */
|
||||
if (mysqli_connect_errno()) {
|
||||
throw new \RuntimeException(mysqli_connect_error());
|
||||
throw new \DatabaseException('', mysqli_connect_error());
|
||||
}
|
||||
/* activate reporting */
|
||||
$driver = new mysqli_driver();
|
||||
@@ -71,5 +71,10 @@ class DBMysqli implements DBInterface
|
||||
return $this->mysqli->real_escape_string($string);
|
||||
}
|
||||
|
||||
public function lastInsertId(): int
|
||||
{
|
||||
return $this->mysqli->insert_id;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -55,3 +55,7 @@ function mysql_real_escape_string($string)
|
||||
return DB::getInstance()->escapeString($string);
|
||||
}
|
||||
|
||||
function mysql_insert_id()
|
||||
{
|
||||
return DB::getInstance()->lastInsertId();
|
||||
}
|
||||
|
||||
@@ -24,4 +24,6 @@ interface DBInterface
|
||||
|
||||
public function escapeString(string $string): string;
|
||||
|
||||
public function lastInsertId(): int;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user