The $sql is created with this:
$i=0; // This is each counter
// Now build SQL String
$sql = "";
foreach ($string as $key => $value)
{
$value = trim($value);
//strip white space befor and after each term
$sql.= "Post.title LIKE '%" . $value . "%' OR
Post.description LIKE '%" . $value . "%'";
$i++; // Put your counter up by 1
if($i < count($string)) // Check if your counter is
smaller than amount of values in array, if there are still values, add a OR
{
$sql.=" OR ";
}
}
So it ends up with `Post`.`title` LIKE '%mary%' OR `Post`.`description` LIKE
'%mary%'
-----Original Message-----
From: Miles J [mailto:[email protected]]
Sent: September-06-09 4:42 PM
To: CakePHP
Subject: Re: Query Help
It seems like the OR is breaking it. What does the $sql variable look like?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---