1
0
mirror of https://github.com/dg/dibi.git synced 2025-08-17 03:24:21 +02:00

- DibiConnection: insert() and update() accepts ArrayObject

This commit is contained in:
David Grudl
2009-06-19 11:28:42 +00:00
parent 74178a5596
commit e52cee8cbc
3 changed files with 13 additions and 5 deletions

View File

@@ -581,8 +581,11 @@ class DibiConnection extends DibiObject
* @param array
* @return DibiFluent
*/
public function update($table, array $args)
public function update($table, $args)
{
if (!(is_array($args) || $args instanceof ArrayObject)) {
throw new InvalidArgumentException('Arguments must be array or ArrayObject.');
}
return $this->command()->update('%n', $table)->set($args);
}
@@ -593,8 +596,13 @@ class DibiConnection extends DibiObject
* @param array
* @return DibiFluent
*/
public function insert($table, array $args)
public function insert($table, $args)
{
if ($args instanceof ArrayObject) {
$args = (array) $args;
} elseif (!is_array($args)) {
throw new InvalidArgumentException('Arguments must be array or ArrayObject.');
}
return $this->command()->insert()
->into('%n', $table, '(%n)', array_keys($args))->values('%l', array_values($args));
}