Beispiel #1
0
 /**
  * parseWhere
  *
  * @param AbstractQuery $query
  * @param array $key
  */
 private function parseWhere(AbstractQuery $query, array $key)
 {
     foreach ($key as $index => $where) {
         if (is_int($index) && is_array($where)) {
             call_user_func_array(array($query, 'where'), $where);
         } else {
             $query->where("{$index} = ?", $where);
         }
     }
 }
 /**
  * parseWhere  
  * 
  * @param Query $query 
  * @access protected
  * @return string
  */
 protected function parseWhere(Query $query)
 {
     $where = $query->getQuery('where');
     $str = '';
     if (!empty($where)) {
         $str = 'WHERE 1 = 1';
         foreach ($where as $condition) {
             list($op, $args) = $condition;
             $expression = array_shift($args);
             $args = array_map(array($this, 'parseValue'), $args);
             array_unshift($args, str_replace('?', '%s', $expression));
             $str .= " {$op} (" . call_user_func_array('sprintf', $args) . ')';
         }
     }
     return $str;
 }