Esempio n. 1
0
 /**
  * Processa a query de consulta
  * @param Expression $qry
  * @return array No formato queryresult
  */
 protected function proccessQuery(Expression $qry)
 {
     $params = array();
     $sql = '';
     if ($qry->hasWhere()) {
         $sql = $qry->getWhere()->getSQL() . ' ';
         $params = $qry->getWhere()->getParams();
     }
     if ($qry->hasGroupBy()) {
         $sql .= 'GROUP BY ' . implode(',', $qry->getGroupBy()) . ' ';
     }
     if ($qry->hasHaving()) {
         $count = 1;
         $sql .= str_replace('WHERE', 'HAVING', $qry->getHaving()->getSQL(), $count) . ' ';
         $params = array_merge($params, $qry->getHaving()->getParams());
     }
     if ($qry->hasOrderBy()) {
         $order = array();
         foreach ($qry->getOrderBy() as $cp => $ord) {
             $order[] = $cp . ' ' . $ord;
         }
         $sql .= 'ORDER BY ' . implode(',', $order) . ' ';
     }
     if ($qry->hasLimit()) {
         $sql .= 'LIMIT ? ';
         $params[] = $qry->getLimit();
     }
     if ($qry->hasOffset() && $qry->getOffset() > 0) {
         $sql .= 'OFFSET ? ';
         $params[] = $qry->getOffset();
     }
     return $this->getQueryResult($sql, $params);
 }
Esempio n. 2
0
 /**
  * @covers Expression::getInstance
  * @todo   Implement testGetInstance().
  */
 public function testGetInstance()
 {
     $this->object = Expression::getInstance(array('x' => 'y'));
     $this->assertFalse($this->object->hasWhere(), 'Falha ao possuir o WHERE');
     $this->assertEquals($this->object, Expression::getInstance($this->object));
 }