diff --git a/src/InsertSelectQuery.php b/src/InsertSelectQuery.php index b8f3270..315209d 100644 --- a/src/InsertSelectQuery.php +++ b/src/InsertSelectQuery.php @@ -60,8 +60,11 @@ public function build(DbFunctionsInterface|DbDriverInterface|null $dbDriverOrHel throw new OrmInvalidFieldsException('You must specify the fields for insert'); } + $dbDriver = null; + $dbHelper = $dbDriverOrHelper; if ($dbDriverOrHelper instanceof DbDriverInterface) { - $dbDriverOrHelper = $dbDriverOrHelper->getDbHelper(); + $dbDriver = $dbDriverOrHelper; + $dbHelper = $dbDriverOrHelper->getDbHelper(); } if (empty($this->query) && empty($this->sqlObject)) { @@ -71,13 +74,13 @@ public function build(DbFunctionsInterface|DbDriverInterface|null $dbDriverOrHel } $fieldsStr = $this->fields; - if (!is_null($dbDriverOrHelper)) { - $fieldsStr = $dbDriverOrHelper->delimiterField($fieldsStr); + if (!is_null($dbHelper)) { + $fieldsStr = $dbHelper->delimiterField($fieldsStr); } $tableStr = $this->table; - if (!is_null($dbDriverOrHelper)) { - $tableStr = $dbDriverOrHelper->delimiterTable($tableStr); + if (!is_null($dbHelper)) { + $tableStr = $dbHelper->delimiterTable($tableStr); } $sql = 'INSERT INTO ' @@ -87,7 +90,7 @@ public function build(DbFunctionsInterface|DbDriverInterface|null $dbDriverOrHel if (!is_null($this->sqlObject)) { $fromObj = $this->sqlObject; } else { - $fromObj = $this->query->build(); + $fromObj = $this->query->build($dbDriver); } return new SqlObject($sql . $fromObj->getSql(), $fromObj->getParameters()); diff --git a/src/Literal/HexUuidLiteral.php b/src/Literal/HexUuidLiteral.php index cc6c6dd..5ca21da 100644 --- a/src/Literal/HexUuidLiteral.php +++ b/src/Literal/HexUuidLiteral.php @@ -11,7 +11,7 @@ class HexUuidLiteral extends Literal protected string $formattedUuid; - public function __construct(HexUuidLiteral|string $value) + public function __construct(Literal|string $value) { parent::__construct($this->binaryString($value)); } @@ -39,7 +39,7 @@ public static function create(mixed $value): mixed /** * @throws InvalidArgumentException */ - public function binaryString(HexUuidLiteral|string $value): string + public function binaryString(Literal|string $value): string { if ($value instanceof HexUuidLiteral) { $value = $value->formattedUuid; @@ -66,7 +66,7 @@ public static function getUuidFromLiteral(HexUuidLiteral $literal): string /** * @throws InvalidArgumentException */ - public static function getFormattedUuid(HexUuidLiteral|string|null $item, bool $throwErrorIfInvalid = true, $default = null): ?string + public static function getFormattedUuid(Literal|string|null $item, bool $throwErrorIfInvalid = true, $default = null): ?string { if ($item instanceof Literal) { $item = $item->__toString(); diff --git a/src/Literal/MySqlUuidLiteral.php b/src/Literal/MySqlUuidLiteral.php index 18d23e3..dec9a16 100644 --- a/src/Literal/MySqlUuidLiteral.php +++ b/src/Literal/MySqlUuidLiteral.php @@ -4,7 +4,7 @@ class MySqlUuidLiteral extends HexUuidLiteral { - public function __construct(HexUuidLiteral|string $value) + public function __construct(Literal|string $value) { if ($value instanceof HexUuidLiteral) { $value = $value->formattedUuid; diff --git a/src/Literal/PostgresUuidLiteral.php b/src/Literal/PostgresUuidLiteral.php index b6bd1cc..6d0ddef 100644 --- a/src/Literal/PostgresUuidLiteral.php +++ b/src/Literal/PostgresUuidLiteral.php @@ -4,7 +4,7 @@ class PostgresUuidLiteral extends HexUuidLiteral { - public function __construct(HexUuidLiteral|string $value) + public function __construct(Literal|string $value) { if ($value instanceof HexUuidLiteral) { $value = $value->formattedUuid; diff --git a/src/Literal/SqlServerUuidLiteral.php b/src/Literal/SqlServerUuidLiteral.php index fa6437c..fc0e86f 100644 --- a/src/Literal/SqlServerUuidLiteral.php +++ b/src/Literal/SqlServerUuidLiteral.php @@ -4,7 +4,7 @@ class SqlServerUuidLiteral extends HexUuidLiteral { - public function __construct(HexUuidLiteral|string $value) + public function __construct(Literal|string $value) { if ($value instanceof HexUuidLiteral) { $value = $value->formattedUuid; diff --git a/src/Literal/SqliteUuidLiteral.php b/src/Literal/SqliteUuidLiteral.php index d77b81c..b6098a0 100644 --- a/src/Literal/SqliteUuidLiteral.php +++ b/src/Literal/SqliteUuidLiteral.php @@ -4,7 +4,7 @@ class SqliteUuidLiteral extends HexUuidLiteral { - public function __construct(HexUuidLiteral|string $value) + public function __construct(Literal|string $value) { if ($value instanceof HexUuidLiteral) { $value = $value->formattedUuid; diff --git a/src/UpdateQuery.php b/src/UpdateQuery.php index d68172f..5b072ef 100644 --- a/src/UpdateQuery.php +++ b/src/UpdateQuery.php @@ -58,7 +58,7 @@ public function set(string $field, int|float|bool|string|LiteralInterface|null $ * Set a field with a literal value that will be used directly in the SQL query * * @param string $field - * @param string $value + * @param mixed $value * @return $this */ public function setLiteral(string $field, mixed $value): UpdateQuery @@ -70,11 +70,10 @@ public function setLiteral(string $field, mixed $value): UpdateQuery protected function getJoinTables(DbFunctionsInterface|DbDriverInterface $dbDriverOrHelper = null): array { $dbDriver = null; + $dbHelper = $dbDriverOrHelper; if ($dbDriverOrHelper instanceof DbDriverInterface) { $dbDriver = $dbDriverOrHelper; $dbHelper = $dbDriverOrHelper->getDbHelper(); - } else { - $dbHelper = $dbDriverOrHelper; } if (is_null($dbHelper)) {