Example #1
0
 /**
  * Generate the where clause.
  *
  * @return string The ready to use where clause.
  */
 function filter()
 {
     if (strlen($this->where_clause) > 0) {
         return $this->where_clause;
     }
     if (!is_null($this->forced_where) or strlen($this->search_string) > 0 && !empty($this->search_fields)) {
         $lastsql = new Pluf_SQL();
         $keywords = $lastsql->keywords($this->search_string);
         foreach ($keywords as $key) {
             $sql = new Pluf_SQL();
             foreach ($this->search_fields as $field) {
                 $sqlor = new Pluf_SQL();
                 $sqlor->Q($field . ' LIKE %s', '%' . $key . '%');
                 $sql->SOr($sqlor);
             }
             $lastsql->SAnd($sql);
         }
         if (!is_null($this->forced_where)) {
             $lastsql->SAnd($this->forced_where);
         }
         $this->where_clause = $lastsql->gen();
         if (strlen($this->where_clause) == 0) {
             $this->where_clause = null;
         }
     }
     return $this->where_clause;
 }