- Added some more debug info, fixed missing interface on Entity
This commit is contained in:
parent
033a183269
commit
2e45eba520
@ -19,7 +19,7 @@ class PdoObject extends PDO {
|
|||||||
|
|
||||||
public function select(string $sql, array $parameters = []): PDOStatement
|
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 {
|
try {
|
||||||
if (false !== ( $statement = $this->prepare($sql) )) {
|
if (false !== ( $statement = $this->prepare($sql) )) {
|
||||||
@ -43,7 +43,7 @@ class PdoObject extends PDO {
|
|||||||
|
|
||||||
public function runQuery(string $sql, array $parameters = []): ? static
|
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 {
|
try {
|
||||||
if (false !== ( $statement = $this->prepare($sql) )) {
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,11 +5,11 @@ namespace Ulmus\Entity\InformationSchema;
|
|||||||
use Notes\Common\ReflectedProperty;
|
use Notes\Common\ReflectedProperty;
|
||||||
use Ulmus\Entity\Field\Datetime;
|
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};
|
use Ulmus\Attribute\Property\{Field, Filter, FilterJoin, Relation, Join, Virtual, Where};
|
||||||
|
|
||||||
#[Table(name: "columns", database: "information_schema")]
|
#[Table(name: "columns", database: "information_schema")]
|
||||||
class Column
|
class Column implements EntityInterface
|
||||||
{
|
{
|
||||||
use \Ulmus\EntityTrait;
|
use \Ulmus\EntityTrait;
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ use Ulmus\{Attribute\Obj\Table as TableObj, Entity\EntityInterface};
|
|||||||
use Ulmus\Attribute\Property\{Field, Filter, FilterJoin, Relation, Join, Virtual, Where};
|
use Ulmus\Attribute\Property\{Field, Filter, FilterJoin, Relation, Join, Virtual, Where};
|
||||||
|
|
||||||
#[TableObj(name: "tables", database: "information_schema")]
|
#[TableObj(name: "tables", database: "information_schema")]
|
||||||
class Table
|
class Table implements EntityInterface
|
||||||
{
|
{
|
||||||
use \Ulmus\EntityTrait;
|
use \Ulmus\EntityTrait;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user