public function testArrayFlatten() { $utils = new Utils(); $this->assertEquals([], $utils->arrayFlatten([])); $this->assertEquals([1], $utils->arrayFlatten([1])); $this->assertEquals([1], $utils->arrayFlatten([[1]])); $this->assertEquals([1, 2], $utils->arrayFlatten([[1, 2]])); $this->assertEquals([1, 2], $utils->arrayFlatten([[1], 2])); $this->assertEquals([1, 2], $utils->arrayFlatten([1, [2]])); $this->assertEquals([1, 2, 3], $utils->arrayFlatten([1, [2], 3])); $this->assertEquals([1, 2, 3, 4], $utils->arrayFlatten([1, [2, 3], 4])); $this->assertEquals([1, 2, 3, 4, 5, 6], $utils->arrayFlatten([1, [2, 3], 4, [5, 6]])); }
private function applyWhereConditions($args) { require_once 'Expressions.php'; $num_args = \count($args); if ($num_args == 1 && Utils::isHash($args[0])) { $hash = \is_null($this->joins) ? $args[0] : $this->prependTableNameToFields($args[0]); $e = new Expressions($this->connection, $hash); $this->where = $e->toString(); $this->where_values = Utils::arrayFlatten($e->values()); } elseif ($num_args > 0) { // if the values has a nested array then we'll need to use Expressions to expand the bind marker for us $values = \array_slice($args, 1); // foreach ($values as $name => &$value) oiginal foreach ($values as &$value) { if (\is_array($value)) { $e = new Expressions($this->connection, $args[0]); $e->bindValues($values); $this->where = $e->toString(); $this->where_values = Utils::arrayFlatten($e->values()); return; } } // no nested array so nothing special to do $this->where = $args[0]; $this->where_values =& $values; } }