I use classic php:
-- $link = mysql_connect("localhost", $db, $psw) or die("No connect MySQL.");
mysql_select_db($db) or die("No connect DB.");
if(!empty($word_1)){$word_1 = "kw LIKE '%{$word_1}%'" ;}else{$word_1 = null ;}
if(!empty($word_2)){$word_2 = " AND kw LIKE '%{$word_2}%'" ;}else{$word_2 = null ;}
if(!empty($word_3)){$word_3 = " AND kw LIKE '%{$word_3}%'" ;}else{$word_3 = null ;}
if(!empty($word_4)){$word_4 = ") OR (kw LIKE '%{$word_4}%'" ;}else{$word_4 = null ;}
if(!empty($word_5)){$word_5 = " AND kw LIKE '%{$word_5}%'" ;}else{$word_5 = null ;}
if(!empty($word_6)){$word_6 = " AND kw LIKE '%{$word_6}%'" ;}else{$word_6 = null ;}
if(!empty($word_7)){$word_7 = ") AND NOT (kw LIKE '%{$word_7}%'" ;}else{$word_7 = null ;}
if(!empty($word_8)){$word_8 = " OR kw LIKE '%{$word_8}%'" ;}else{$word_8 = null ;}
if(!empty($word_9)){$word_9 = " OR kw LIKE '%{$word_9}%'" ;}else{$word_9 = null ;}
$query = "SELECT * FROM keywords WHERE
(({$word_1}{$word_2}{$word_3}{$word_4}{$word_5}{$word_6}){$word_7}{$word_8}{$word_9}) order by frequency desc";
$res = mysql_query($query);
while($row = mysql_fetch_array($res)){$result[$row['id']]['kw'] = $row['kw'];
$result[$row['id']]['id'] = $row['id'];
$result[$row['id']]['frequency'] = $row['frequency'];}
mysql_close($link);
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment