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

  • SEARCH
  • Home
  • 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 5995727
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:00:07+00:00 2026-05-23T00:00:07+00:00

can any one help me out iam running a query using doctrine. i made

  • 0

can any one help me out

iam running a query using doctrine.

i made indexing and foriegnkey reference for necessary tables

here is my query

echo "step1";echo date('h:i:s A');echo "<br/>";
        $query = new Doctrine_Query();
        $whereCond ='';
        $where='eng.id='.$campid;
        $select='';
        $search = '';
        /*if($queryv!=''){

             $where .= " AND c.".$quickSearchType." LIKE '%".$queryv."%' ";
        }*/
        if($letterPressed == 'All')
        {
            $where .="";
        }
        else if($letterPressed == 'Radian6')
        {
            $where .=" AND c.news_type = 1";
        }
        else if($letterPressed == 'Google News')
        {
            $where .=" AND c.news_type = 3";
        }
        else if($letterPressed == 'Google Blogs')
        {
            $where .=" AND c.news_type = 4";
        }
        else if($letterPressed == 'RSS Feeds')
        {
            $where .=" AND (c.news_type = 5 or  c.news_type = 6)";
        }
        else if($letterPressed == 'Hide Twitter')
        {
            $where .=" AND c.url NOT LIKE '%twitter.com%'";
        }
        else if($letterPressed == 'Hide Facebook')
        {
            $where .=" AND c.url NOT LIKE '%facebook.com%'";
        }
        else if($letterPressed == 'Hide Facebook-twitter')
        {
            $where .=" AND (c.url NOT LIKE '%twitter.com%' AND c.url NOT LIKE '%facebook.com%')";
        }
        else if($letterPressed == 'Show Twitter')
        {
            $where .=" AND c.url LIKE '%twitter.com%'";
        }
        else if($letterPressed == 'Show Facebook')
        {
            $where .=" AND c.url LIKE '%facebook.com%'";
        }
        else if($letterPressed == 'show Facebook-twitter')
        {
            $where .=" AND (c.url  LIKE '%twitter.com%' OR c.url LIKE '%facebook.com%')";
        }

        if($queryv!='' && $quickSearchType == 'title' && (trim($letterPressed) != 'Law' && trim($letterPressed) != 'LS Translate') ){

             $search = ' LOWER(c.title) LIKE "%'.mysql_real_escape_string($queryv).'%" ';
             //$search = ' LOWER(c.title) LIKE ?';
        }
        if($queryv!='' && $quickSearchType == 'domain')
        {
             $search = ' LOWER(c.domain) LIKE "%'.mysql_real_escape_string($queryv).'%" ';
             //$search = ' LOWER(c.domain) LIKE ?';

        }
        echo "step2";echo date('h:i:s A');echo "<br/>";

        $select='c.id, c.campaign_id, c.title as title, c.domain, c.news_type,c.url, c.active, c.article_date, c.created_date, c.modified_date, t.language_id, t.tr_translated_date, t.tr_translated_by, t.translation_state, t.tr_title, t.raw_title';
        if(trim($letterPressed) == 'Original')
        {
            $select='c.id, c.campaign_id, c.title as title, c.domain, c.news_type,c.url, c.active, c.article_date, c.created_date, c.modified_date, t.language_id, t.tr_translated_date, t.tr_translated_by, t.translation_state';
        }
        if(trim($letterPressed) == 'Law')
        {
            $select='c.id, c.campaign_id, c.domain, c.news_type,c.url, c.active,c.article_date, c.created_date, c.modified_date, t.raw_title as title, t.language_id, t.tr_translated_date, t.tr_translated_by, t.translation_state';
            if($queryv!='' && $quickSearchType == 'title'){

             $search = ' LOWER(t.raw_title) LIKE "%'.mysql_real_escape_string($queryv).'%"';
             //$search = ' LOWER(t.raw_title) LIKE ?';

            }
        }
        if(trim($letterPressed) == 'LS Translate')
        {
            $select='c.id, c.campaign_id, c.domain, c.news_type,c.url, c.active, c.article_date, c.created_date, c.modified_date, t.tr_title as title, t.language_id, t.tr_translated_date, t.tr_translated_by, t.translation_state';
            $where .=" AND t.translation_state = 1";
            if($queryv!='' && $quickSearchType == 'title'){

             $search = ' LOWER(t.tr_title) LIKE "%'.mysql_real_escape_string($queryv).'%" ';
             //$search = ' LOWER(t.tr_title) LIKE ?';
            }
        }
        $whereCond.=$where;  
        // , array("%".mysql_real_escape_string($queryv)."%")
        echo "step3";echo date('h:i:s A');echo "<br/>";
        $query->select($select)
              ->from('News c')
              ->where($whereCond)
               ->addWhere('eng.tr_language_id=t.language_id')
               ->andWhere('c.created_date >= DATE_SUB(CURDATE(),INTERVAL 90 DAY)' );
        if(!empty($search))
            $query->andWhere($search);     
        $query->leftJoin('c.TranslatedNews t on t.news_id = c.id')
              ->leftJoin('c.Campaigns eng on eng.id = c.campaign_id')            
              ->orderBy('c.'.$sortName. ' ' . $sortOrder)
              ->groupBy('c.title')
              ->addGroupBy('c.url')
              ->limit(10);
            echo "step4";echo date('h:i:s A');echo "<br/>"; 
            //echo $query->getSqlQuery();exit;
            $result = $query->execute(array(),Doctrine::HYDRATE_ARRAY);
            echo "step5";echo date('h:i:s A');echo "<br/>";exit;
            return $result;

for executing query it is taking 8 sec .
How to make this query to run fast

Thanks in advance

  • 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-05-23T00:00:08+00:00Added an answer on May 23, 2026 at 12:00 am

    Your LIKE comparison is actually a “contains-substring” search when you put wildcard book-ends on the %search-term%. The typical advantages of a sorted index are not available on searches like this (because your wildcard says to ignore the characters at the start of the value); and so every value in the table (in the relevant column) must be examined to see if it contains the substring.

    If you searched the phone book WHERE SURNAME LIKE ‘%els%’ you would have to examine every surname, whereas if you did WHERE SURNAME LIKE ‘Nels%’ you could search through the -N- names only, excluding names that began with any other letter. The latter could use an index.

    The creators of the database could help you out by extracting the domain from the url and placing the domain in its own column and indexing that column. Then you could do an equality comparison, WHERE DOMAIN = ‘somedomain’ and the value would be found very quickly and efficiently.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can any one help me convert the below code to LINQ? Select Catg,Count(*) From
can any one help me with code that subtract 1 from a digit stored
can any one help me in creating a regular expression for password validation. The
Can any one help me how to sort rows by relevance for the following
I am new in Pocket PC and Smart phone. so can any one help
I am new in Blackberry. Can anyone help me out for following queries? Which
I am new in Symbian UIQ. So anyone can help me out about following
Can anyone help me out please? I'm confused. I want to set up my
Can anyone please help me to work out how to achieve the following? I
Anyone that can help me out will be very much appreciated. I seem to

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.