Here's the query I'm trying to run:
- Code: Select all
SELECT * from (
SELECT
'Tab' as 'table_name', TabId as id, `TabTitle` as title,
(MATCH(`TabTitle`,`TabSubTitle`) AGAINST (@target)) as relevance
from Tab
UNION
SELECT
'Tab2' as 'table_name',
Tab2Id as id, `Tab2Title` as title,
(MATCH(`Tab2Title`,`Tab2Desc`) AGAINST (@target)) as relevance
from Tab2
)
as sitewide WHERE relevance > 0 order by relevance DESC;
I'd like any pointers you can offer as to how to shoehorn this into the MVC framework of Zend!
This is the current Model Code I'm using, which gives an error "Argument 1 passed to Zend_Paginator_Adapter_DbTableSelect::__construct() must be an instance of Zend_Db_Select, string given,"
- Code: Select all
<?php
class Application_Model_Search extends Zend_Db_Table
{
protected $_name = ‘Search’;
protected $_primary = 'SearchId';
function getSearchResults($page, $searchTerm)
{
$query = "
SELECT * from (
SELECT
'Tab' as 'table_name', TabId as id, `TabTitle` as title,
(MATCH(`TabTitle`,`TabSubTitle`) AGAINST (@target)) as relevance
from Tab
UNION
SELECT
'Tab2' as 'table_name',
Tab2Id as id, `Tab2Title` as title,
(MATCH(`Tab2Title`,`Tab2Desc`) AGAINST (@target)) as relevance
from Tab2
)
as sitewide WHERE relevance > 0 order by relevance DESC;
";
echo ($query);
$paginator = new Zend_Paginator(new Zend_Paginator_Adapter_DbTableSelect($query));
$paginator->setItemCountPerPage(15); //
$paginator->setCurrentPageNumber($page);
return $paginator;
}
}

