HosipLan

Untitled

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