0
我在cakePHP中做了一个非常简单的搜索函数,并且想要动态地用for循环来填充数组。从for循环蛋糕创建数组PHPH
我正在考虑创建一个数组来设置put作为第二个参数int find() - 函数。
这是我的静态结果:
$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);
我的第一直觉是这样做的:
$search = $this->request->query['q'];
$words = explode(" ", $search);
$count = count($words);
,然后创建从这个for循环,但 “OR =>” 被导致我很难整合。 任何人都可以帮我做这个循环?
在此先感谢,Jesper。
是的,这正是我所需要的一种智慧。感谢您的澄清:) –