I'm making a very simple search-function in cakePHP, and want to populate an array from a for-loop with arrays dynamically.
I'm thinking of creating an array to set put as second parameter int the find()-function.
This is my static result:
$result = $this->Book->find('all', array('conditions' =>
array("Book.book_title LIKE" => "%war%"),
"OR" =>
array("Book.book_title LIKE" => "%and%"),
"OR" =>
array('Book.book_title LIKE' => "%peace%")
));
$this->set('searchResult', $result);
My first intuition was to do so:
$search = $this->request->query['q'];
$words = explode(" ", $search);
$count = count($words);
And then create a for-loop from this, but the "OR =>" is causing me a lot of trouble to integrate. Can anybody help me to make this for loop?
Thanks in advance, Jesper.