I am making a Zend framework method for a search engine. Because i search through different tables i also have to make two different select variables and return it. My questions are: Is this a good idea for a search engine with different tables?
And how to return the different resuls in an array? (fetchall->$selectMovies, fetchall->$selectPosts)
Thanks and greetz Eric
public function search($keyword) {
$selectPosts = $this->select();
$selectPosts->from('posts', array('*'));
$selectPosts->where('posts.post_title LIKE ? OR posts.post_body LIKE ?', '%'. $keyword . '%' );
$tblMovies = new Model_DbTable_Film();
$selectMovies = $tblMovies->select();
$selectMovies->from('film', array('*'));
$selectMovies->where('film.titel LIKE ? OR film.omschrijving LIKE ?', '%'. $keyword . '%' );
//var_dump($this->fetchAll($selectPosts, $selectMovies)); die;
return $this->fetchAll($selectMovies);
return $this->fetchAll($selectPosts);
}
You can only return once, but what you can do is return an array of your result arrays.
Or split up your method into 2 and pass a type of search as a parameter to the main search method: