diff --git a/src/Common/PdoObject.php b/src/Common/PdoObject.php index 522ceb1..42dbeba 100644 --- a/src/Common/PdoObject.php +++ b/src/Common/PdoObject.php @@ -19,7 +19,7 @@ class PdoObject extends PDO { public function select(string $sql, array $parameters = []): PDOStatement { - static::$dump && call_user_func_array(static::$dump, [ $sql, $parameters ]); + static::$dump && call_user_func_array(static::$dump, [ $this->fillDebugSqlParameters($sql, $parameters) ]); try { if (false !== ( $statement = $this->prepare($sql) )) { @@ -43,7 +43,7 @@ class PdoObject extends PDO { public function runQuery(string $sql, array $parameters = []): ? static { - static::$dump && call_user_func_array(static::$dump, [ $sql, $parameters ]); + static::$dump && call_user_func_array(static::$dump, [ $this->fillDebugSqlParameters($sql, $parameters) ]); try { if (false !== ( $statement = $this->prepare($sql) )) { @@ -131,4 +131,11 @@ class PdoObject extends PDO { } } } + + protected function fillDebugSqlParameters(string $sql, array $parameters) : string + { + $parameters = array_reverse($parameters); + + return str_replace(array_keys($parameters), array_map(fn($e) => is_numeric($e) ? $e : $this->quote($e), array_values($parameters)), $sql); + } } diff --git a/src/Entity/InformationSchema/Column.php b/src/Entity/InformationSchema/Column.php index 914f676..87a8b38 100644 --- a/src/Entity/InformationSchema/Column.php +++ b/src/Entity/InformationSchema/Column.php @@ -5,11 +5,11 @@ namespace Ulmus\Entity\InformationSchema; use Notes\Common\ReflectedProperty; use Ulmus\Entity\Field\Datetime; -use Ulmus\{Attribute\Obj\Table}; +use Ulmus\{Attribute\Obj\Table, Entity\EntityInterface}; use Ulmus\Attribute\Property\{Field, Filter, FilterJoin, Relation, Join, Virtual, Where}; #[Table(name: "columns", database: "information_schema")] -class Column +class Column implements EntityInterface { use \Ulmus\EntityTrait; diff --git a/src/Entity/InformationSchema/Table.php b/src/Entity/InformationSchema/Table.php index 89b9875..d38cadb 100644 --- a/src/Entity/InformationSchema/Table.php +++ b/src/Entity/InformationSchema/Table.php @@ -9,7 +9,7 @@ use Ulmus\{Attribute\Obj\Table as TableObj, Entity\EntityInterface}; use Ulmus\Attribute\Property\{Field, Filter, FilterJoin, Relation, Join, Virtual, Where}; #[TableObj(name: "tables", database: "information_schema")] -class Table +class Table implements EntityInterface { use \Ulmus\EntityTrait;