Esempio n. 1
0
 public function testBindOverwriteExisting()
 {
     $a = new Expressions(null, 'name=? and id=?', 'Tito', 1);
     $a->bind(2, 99);
     $this->assertEquals(['Tito', 99], $a->values());
 }
 public function test_bind_overwrite_existing()
 {
     $a = new Expressions(null, 'name=? and id=?', 'Tito', 1);
     $a->bind(2, 99);
     $this->assert_equals(array('Tito', 99), $a->values());
 }
Esempio n. 3
0
 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;
     }
 }