mirror of
https://github.com/dg/dibi.git
synced 2025-08-05 05:37:39 +02:00
ArrayObject -> Traversable & iterator_to_array
This commit is contained in:
@@ -204,8 +204,8 @@ class dibi
|
||||
|
||||
/**
|
||||
* Creates a new DibiConnection object and connects it to specified database.
|
||||
* @param array|string|ArrayObject connection parameters
|
||||
* @param string connection name
|
||||
* @param mixed connection parameters
|
||||
* @param string connection name
|
||||
* @return DibiConnection
|
||||
* @throws DibiException
|
||||
*/
|
||||
|
@@ -44,8 +44,8 @@ class DibiConnection extends DibiObject
|
||||
|
||||
/**
|
||||
* Creates object and (optionally) connects to a database.
|
||||
* @param array|string|ArrayObject connection parameters
|
||||
* @param string connection name
|
||||
* @param mixed connection parameters
|
||||
* @param string connection name
|
||||
* @throws DibiException
|
||||
*/
|
||||
public function __construct($config, $name = NULL)
|
||||
@@ -58,7 +58,7 @@ class DibiConnection extends DibiObject
|
||||
$config = iterator_to_array($config);
|
||||
|
||||
} elseif (!is_array($config)) {
|
||||
throw new InvalidArgumentException('Configuration must be array, string or ArrayObject.');
|
||||
throw new InvalidArgumentException('Configuration must be array, string or object.');
|
||||
}
|
||||
|
||||
self::alias($config, 'username', 'user');
|
||||
@@ -553,8 +553,8 @@ class DibiConnection extends DibiObject
|
||||
*/
|
||||
public function update($table, $args)
|
||||
{
|
||||
if (!(is_array($args) || $args instanceof ArrayObject)) {
|
||||
throw new InvalidArgumentException('Arguments must be array or ArrayObject.');
|
||||
if (!(is_array($args) || $args instanceof Traversable)) {
|
||||
throw new InvalidArgumentException('Arguments must be array or Traversable.');
|
||||
}
|
||||
return $this->command()->update('%n', $table)->set($args);
|
||||
}
|
||||
@@ -568,10 +568,10 @@ class DibiConnection extends DibiObject
|
||||
*/
|
||||
public function insert($table, $args)
|
||||
{
|
||||
if ($args instanceof ArrayObject) {
|
||||
$args = (array) $args;
|
||||
if ($args instanceof Traversable) {
|
||||
$args = iterator_to_array($args);
|
||||
} elseif (!is_array($args)) {
|
||||
throw new InvalidArgumentException('Arguments must be array or ArrayObject.');
|
||||
throw new InvalidArgumentException('Arguments must be array or Traversable.');
|
||||
}
|
||||
return $this->command()->insert()
|
||||
->into('%n', $table, '(%n)', array_keys($args))->values('%l', $args);
|
||||
|
@@ -132,7 +132,7 @@ class DibiFluent extends DibiObject implements IDataSource
|
||||
} elseif ($arg instanceof self) {
|
||||
$args = array_merge(array('('), $arg->_export(), array(')'));
|
||||
|
||||
} elseif (is_array($arg) || $arg instanceof ArrayObject) { // any array
|
||||
} elseif (is_array($arg) || $arg instanceof Traversable) { // any array
|
||||
if (isset(self::$modifiers[$clause])) {
|
||||
$args = array(self::$modifiers[$clause], $arg);
|
||||
|
||||
|
@@ -134,8 +134,8 @@ final class DibiTranslator extends DibiObject
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($arg instanceof ArrayObject) {
|
||||
$arg = (array) $arg;
|
||||
if ($arg instanceof Traversable) {
|
||||
$arg = iterator_to_array($arg);
|
||||
}
|
||||
|
||||
if (is_array($arg)) {
|
||||
@@ -192,8 +192,8 @@ final class DibiTranslator extends DibiObject
|
||||
public function formatValue($value, $modifier)
|
||||
{
|
||||
// array processing (with or without modifier)
|
||||
if ($value instanceof ArrayObject) {
|
||||
$value = (array) $value;
|
||||
if ($value instanceof Traversable) {
|
||||
$value = iterator_to_array($value);
|
||||
}
|
||||
|
||||
if (is_array($value)) {
|
||||
|
Reference in New Issue
Block a user