mirror of
https://github.com/dg/dibi.git
synced 2025-08-03 12:47:33 +02:00
DibiFluent::__class() small refactoring
This commit is contained in:
@@ -132,29 +132,6 @@ class DibiFluent extends DibiObject implements IDataSource
|
|||||||
$this->cursor = & $this->clauses[self::$clauseSwitches[$clause]];
|
$this->cursor = & $this->clauses[self::$clauseSwitches[$clause]];
|
||||||
}
|
}
|
||||||
|
|
||||||
// special types or argument
|
|
||||||
if (count($args) === 1) {
|
|
||||||
$arg = $args[0];
|
|
||||||
// TODO: really ignore TRUE?
|
|
||||||
if ($arg === TRUE) { // flag
|
|
||||||
$args = array();
|
|
||||||
|
|
||||||
} elseif (is_string($arg) && preg_match('#^[a-z:_][a-z0-9_.:]*$#i', $arg)) { // identifier
|
|
||||||
$args = array('%n', $arg);
|
|
||||||
|
|
||||||
} elseif ($arg instanceof self) {
|
|
||||||
$args = array_merge(array('('), $arg->_export(), array(')'));
|
|
||||||
|
|
||||||
} elseif (is_array($arg) || $arg instanceof Traversable) { // any array
|
|
||||||
if (isset(self::$modifiers[$clause])) {
|
|
||||||
$args = array(self::$modifiers[$clause], $arg);
|
|
||||||
|
|
||||||
} elseif (is_string(key($arg))) { // associative array
|
|
||||||
$args = array('%a', $arg);
|
|
||||||
}
|
|
||||||
} // case $arg === FALSE is handled below
|
|
||||||
}
|
|
||||||
|
|
||||||
if (array_key_exists($clause, $this->clauses)) {
|
if (array_key_exists($clause, $this->clauses)) {
|
||||||
// append to clause
|
// append to clause
|
||||||
$this->cursor = & $this->clauses[$clause];
|
$this->cursor = & $this->clauses[$clause];
|
||||||
@@ -188,6 +165,29 @@ class DibiFluent extends DibiObject implements IDataSource
|
|||||||
$this->cursor = array();
|
$this->cursor = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// special types or argument
|
||||||
|
if (count($args) === 1) {
|
||||||
|
$arg = $args[0];
|
||||||
|
// TODO: really ignore TRUE?
|
||||||
|
if ($arg === TRUE) { // flag
|
||||||
|
return $this;
|
||||||
|
|
||||||
|
} elseif (is_string($arg) && preg_match('#^[a-z:_][a-z0-9_.:]*$#i', $arg)) { // identifier
|
||||||
|
$args = array('%n', $arg);
|
||||||
|
|
||||||
|
} elseif ($arg instanceof self) {
|
||||||
|
$args = array_merge(array('('), $arg->_export(), array(')'));
|
||||||
|
|
||||||
|
} elseif (is_array($arg) || $arg instanceof Traversable) { // any array
|
||||||
|
if (isset(self::$modifiers[$clause])) {
|
||||||
|
$args = array(self::$modifiers[$clause], $arg);
|
||||||
|
|
||||||
|
} elseif (is_string(key($arg))) { // associative array
|
||||||
|
$args = array('%a', $arg);
|
||||||
|
}
|
||||||
|
} // case $arg === FALSE is handled above
|
||||||
|
}
|
||||||
|
|
||||||
array_splice($this->cursor, count($this->cursor), 0, $args);
|
array_splice($this->cursor, count($this->cursor), 0, $args);
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user