Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8778113
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T19:26:50+00:00 2026-06-13T19:26:50+00:00

I have to confess that I cannot work out how to complete this. I

  • 0

I have to confess that I cannot work out how to complete this. I can get the query working in MySql, and I can get simple table-or-view queries in Zend Framework, but this is beyond me!

Here’s the query I’m trying to run:

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!

Edited to add:

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,”

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; 


}


}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T19:26:51+00:00Added an answer on June 13, 2026 at 7:26 pm
        $config = array (
            'dbname' => 'test',
            'password' => 'passwd',
            'username' => 'user'
        );
    
        $database = new Zend_Db_Adapter_Mysqli ($config);
    
        $query_1 = new Zend_Db_Select ($database);
        $query_1->from ('Tab', array (
            'Tab AS table_name',
            'TabId AS id',
            'TabTitle` as title',
            new Zend_Db_Expr ('(MATCH(`TabTitle`,`TabSubTitle`) AGAINST (@target)) as relevance')
        ));
    
        $query_2 = new Zend_Db_Select ($database);
        $query_2->from ('Tab2', array (
            'Tab2 AS table_name',
            'Tab2Id AS id',
            'Tab2Title` as title',
            new Zend_Db_Expr ('(MATCH(`Tab2Title`,`TabDesc`) AGAINST (@target)) as relevance')
        ));
    
        $query = $database->select ()
            ->union (array (
            $query_1,
            $query_2
        ));
    
        echo $database->select ()->from ($query)->where ('relevance>0')
            ->order ('relevance DESC');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So, my problem is this. I have a legacy MySQL database that I'm building
I have to confess that I hate membership provider. The default implementation is not
I have written a table-valued UDF that starts by a CTE to return a
I have to confess I've had this question for a very long time and
I have a FragmentActivity that sets up a tabhost. Each tab is a simple
Ok, this is really difficult to confess, but I do have a strong temptation
I have used mnesia for a while now. I have to confess that i
i like to confess that i am weak in LINQ. i have list with
I found this little gem in our codebase at work recently. I have to
I have a query that I run once a day that takes certain tables

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.