diff --git a/system/libs/pot/OTS_Base_DB.php b/system/libs/pot/OTS_Base_DB.php index 8b89dfa5..e6ffa9be 100644 --- a/system/libs/pot/OTS_Base_DB.php +++ b/system/libs/pot/OTS_Base_DB.php @@ -23,6 +23,7 @@ */ abstract class OTS_Base_DB extends PDO implements IOTS_DB { + use OTS_DB_PDOQuery; /** * Tables prefix. * @@ -74,7 +75,7 @@ abstract class OTS_Base_DB extends PDO implements IOTS_DB return $this->fieldName($this->prefix . $name); } - public function query($query) + private function doQuery(...$args) { $this->queries++; @@ -82,7 +83,7 @@ abstract class OTS_Base_DB extends PDO implements IOTS_DB $startTime = microtime(true); } - $ret = parent::query($query); + $ret = parent::query(...$args);; if($this->logged) { $totalTime = microtime(true) - $startTime; $this->log .= round($totalTime, 4) . ' ms - ' . $query . PHP_EOL; diff --git a/system/libs/pot/OTS_DB_PDOQuery.php b/system/libs/pot/OTS_DB_PDOQuery.php new file mode 100644 index 00000000..24ebfa3a --- /dev/null +++ b/system/libs/pot/OTS_DB_PDOQuery.php @@ -0,0 +1,25 @@ += 80000) { + trait OTS_DB_PDOQuery + { + /** + * @return PDOStatement + */ + public function query(?string $query = null, ?int $fetchMode = null, mixed ...$fetchModeArgs) + { + return $this->doQuery($query, $fetchMode, ...$fetchModeArgs); + } + } +} else { + trait OTS_DB_PDOQuery + { + /** + * @return PDOStatement + */ + public function query() + { + return $this->doQuery(...func_get_args()); + } + } +} diff --git a/system/libs/pot/OTS_MonstersList.php b/system/libs/pot/OTS_MonstersList.php index b33bcf57..22ef6df7 100644 --- a/system/libs/pot/OTS_MonstersList.php +++ b/system/libs/pot/OTS_MonstersList.php @@ -86,7 +86,7 @@ class OTS_MonstersList implements Iterator, Countable, ArrayAccess * * @param array $properties List of object properties. */ - public function __set_state($properties) + public static function __set_state($properties) { $object = new self(); diff --git a/system/libs/pot/OTS_SpellsList.php b/system/libs/pot/OTS_SpellsList.php index 5c2a91c3..c7a91899 100644 --- a/system/libs/pot/OTS_SpellsList.php +++ b/system/libs/pot/OTS_SpellsList.php @@ -72,7 +72,7 @@ class OTS_SpellsList implements IteratorAggregate, Countable * * @param array $properties List of object properties. */ - public function __set_state($properties) + public static function __set_state($properties) { $object = new self();