@@ -2,7 +2,6 @@
|
||||
|
||||
namespace Core;
|
||||
|
||||
use Exception;
|
||||
use PDO;
|
||||
use PDOException;
|
||||
use PDOStatement;
|
||||
@@ -15,14 +14,14 @@ class Db
|
||||
|
||||
/**
|
||||
* DB constructor.
|
||||
* @throws Exception
|
||||
* @throws PDOException
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
try {
|
||||
self::$db = Database::pdoinit();
|
||||
} catch (PDOException $e) {
|
||||
throw new Exception($e->getMessage());
|
||||
throw new PDOException($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,19 +54,20 @@ class Db
|
||||
* @param string $query
|
||||
* @return int
|
||||
*/
|
||||
static public function exec(string $query): int
|
||||
public static function exec(string $query): int
|
||||
{
|
||||
self::init();
|
||||
return self::$db->exec($query);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ?string $name [optional] Name of the sequence object from which the ID should be returned.
|
||||
* @return string
|
||||
*/
|
||||
static public function lastInsertId(): string
|
||||
public static function lastInsertId(?string $name = null): string
|
||||
{
|
||||
self::init();
|
||||
return self::$db->lastInsertId();
|
||||
return self::$db->lastInsertId($name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user