HosipLan

Untitled

Aug 20th, 2011
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.51 KB | None | 0 0
  1. $query = $this->db->select('*')->from('table');
  2.  
  3. $ft_min_word_len = $this->db->fetchSingle("SHOW VARIABLES LIKE 'ft_min_word_len'");
  4. preg_match_all("~[\\pL\\pN_]+('[\\pL\\pN_]+)*~u", stripslashes($_GET["search"]), $matches);
  5.  
  6. foreach ($matches[0] as $part) {
  7.     if (iconv_strlen($part, "utf-8") < $ft_min_word_len) {
  8.         $regexp = "[[:<:]]" . $this->db->driver->escape($part, 's') . "[[:>:]]";
  9.     $query->where("([z.cz_nazev] %sql OR [z.cz_popis] %sql)", $regexp, $regexp);
  10.     }
  11. }
  12.  
  13.  
  14. $query->fetchAll();
Advertisement
Add Comment
Please, Sign In to add comment