Example #1
0
 protected function executeDelete(Meta $meta, Query\Criteria $criteria)
 {
     $table = $criteria->table ?: $meta->table;
     list($whereClause, $whereParams, $whereProps) = $criteria->buildClause($meta);
     if (!$whereClause) {
         throw new \UnexpectedValueException("Empty where clause");
     }
     if ($whereProps) {
         $whereParams = $this->mapper->formatParams($meta, $whereProps, $whereParams);
     }
     $t = ($meta->schema ? "`{$meta->schema}`." : null) . "`{$table}`";
     $sql = "DELETE FROM {$t} WHERE {$whereClause}";
     $stmt = $this->getConnector()->prepare($sql)->execute($whereParams);
 }
Example #2
0
 /**
  * @covers Amiss\Sql\Query\Criteria::buildClause
  * @dataProvider dataForBuildClauseFromArrayWithFieldSubstitution
  */
 public function testBuildClauseFieldSubstitutionWithArray($query, $expected)
 {
     $criteria = new Query\Criteria();
     $meta = new \Amiss\Meta('stdClass', array('table' => 'std_class', 'fields' => array('foo' => array('name' => 'foo_field'), 'bar' => array('name' => 'bar_field'))));
     $criteria->where = $query;
     list($where, $params) = $criteria->buildClause($meta);
     $this->assertEquals($expected, $where);
 }