mirror of
https://github.com/dg/dibi.git
synced 2025-08-05 05:37:39 +02:00
- DibiConnection: insert() and update() accepts ArrayObject
This commit is contained in:
@@ -536,7 +536,7 @@ class dibi
|
||||
* @param array
|
||||
* @return DibiFluent
|
||||
*/
|
||||
public static function update($table, array $args)
|
||||
public static function update($table, $args)
|
||||
{
|
||||
return self::getConnection()->update($table, $args);
|
||||
}
|
||||
@@ -548,7 +548,7 @@ class dibi
|
||||
* @param array
|
||||
* @return DibiFluent
|
||||
*/
|
||||
public static function insert($table, array $args)
|
||||
public static function insert($table, $args)
|
||||
{
|
||||
return self::getConnection()->insert($table, $args);
|
||||
}
|
||||
|
@@ -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));
|
||||
}
|
||||
|
@@ -126,7 +126,7 @@ class DibiFluent extends DibiObject implements IDataSource
|
||||
} elseif ($arg instanceof self) {
|
||||
$args = array_merge(array('('), $arg->_export(), array(')'));
|
||||
|
||||
} elseif (is_array($arg)) { // any array
|
||||
} elseif (is_array($arg) || $arg instanceof ArrayObject) { // any array
|
||||
if (isset(self::$modifiers[$clause])) {
|
||||
$args = array(self::$modifiers[$clause], $arg);
|
||||
|
||||
|
Reference in New Issue
Block a user