diff --git a/src/Dibi/Connection.php b/src/Dibi/Connection.php index 1fc8dc31b..3e6a05c56 100644 --- a/src/Dibi/Connection.php +++ b/src/Dibi/Connection.php @@ -441,7 +441,10 @@ public function select(...$args): Fluent } - public function update(string $table, iterable $args): Fluent + /** + * @param string|string[] $table + */ + public function update($table, iterable $args): Fluent { return $this->command()->update('%n', $table)->set($args); } diff --git a/src/Dibi/dibi.php b/src/Dibi/dibi.php index 3bd6bb4e7..7e81442fc 100644 --- a/src/Dibi/dibi.php +++ b/src/Dibi/dibi.php @@ -28,7 +28,7 @@ * @method Dibi\Reflection\Database getDatabaseInfo() * @method Dibi\Fluent command() * @method Dibi\Fluent select(...$args) - * @method Dibi\Fluent update(string $table, array $args) + * @method Dibi\Fluent update(string|string[] $table, array $args) * @method Dibi\Fluent insert(string $table, array $args) * @method Dibi\Fluent delete(string $table) * @method Dibi\HashMap getSubstitutes() diff --git a/tests/dibi/Fluent.update.phpt b/tests/dibi/Fluent.update.phpt index d4d160d09..1d4ab3af7 100644 --- a/tests/dibi/Fluent.update.phpt +++ b/tests/dibi/Fluent.update.phpt @@ -29,3 +29,15 @@ Assert::same( reformat('UPDATE IGNORE DELAYED [table] SET [title]=\'Super Product\', [price]=12, [brand]=NULL , [another]=123'), (string) $fluent ); + + +$arr = [ + 'table1.title' => 'Super Product', + 'table2.price' => 12, + 'table2.brand' => null, +]; +$fluent = $conn->update(['table1', 'table2'], $arr); +Assert::same( + reformat('UPDATE [table1], [table2] SET [table1].[title]=\'Super Product\', [table2].[price]=12, [table2].[brand]=NULL'), + (string) $fluent +);