示例#1
0
 /**
  * @param  FilterInterface $filter
  *
  * @return string
  */
 public static function select($filter)
 {
     $k = 0;
     $statement = "SELECT ";
     foreach ($filter->select() as $key => $value) {
         if ($k != 0) {
             $statement .= ', ';
         }
         $statement .= '`' . $value['0'] . '`.`' . $value['1'] . '`';
         $k++;
     }
     $statement .= " FROM ";
     $k = 0;
     foreach ($filter->from() as $key => $value) {
         if ($k != 0) {
             $statement .= ', ';
         }
         $statement .= '`' . $value . '`';
         $k++;
     }
     $statement .= " WHERE 1=1 ";
     $k = 0;
     foreach ($filter->where() as $key => $value) {
         $statement .= ' AND ';
         if ($value['equal']) {
             $equal = '=';
         } else {
             $equal = '!=';
         }
         if ($value['value'][0] == '`' or is_int($value['value'])) {
             $result = $value['value'];
         } else {
             $result = "'" . $value['value'] . "'";
         }
         $statement .= '`' . $value['source'] . '`.`' . $value['field'] . '`' . $equal . $result;
         $k++;
     }
     $statement .= $filter->limit();
     return $statement;
 }
示例#2
0
 /**
  * @param  FilterInterface $filter
  *
  * @return string
  */
 public static function select(FilterInterface $filter)
 {
     return md5($filter->getSource() . '_' . $filter->getId() . '_' . json_encode($filter->getParameters()));
 }