Ezresults & subqueries

Rate this:
By bkramer (Contact - View My Woyano)
Published Thu 22 Mar 2007, 512 Views, 3 Comments

so I was using ezresults last night and found an issue where ezresults didn't setup the paging correctly for my query. after searching for the reason why I found out that the get_num_results() function didn't like subqueries at all

get_num_results() takes the query and changes everything between the word Select in your query and From. The problem is that if you have a subquery you could have more than 1  instance of the words Select in your overall query.

this may not be the appropriate way to fix the issue but here is how I fixed it.

on line 622 you have the below code:

 $this->num_results =  $db->get_var(preg_replace("/SELECT.*FROM/Ui","SELECT count(*) FROM",$query));

replace it with this code:

 $this->num_results =  $db->get_var(preg_replace("/1-SELECT.*FROM/Ui","SELECT count(*) FROM","1-".$query)); 

for this example I added a "1-" to the start of the query and to the start of the regular expression. by doing this it will only change the text for the start of the query.

 

 



This Item
Category: Bigups, Technology
Tags: ezsql ezresults
Contributor
bkramer
Share it
Link to this item:
Bookmark this item: RSS Feed

People who liked this item

    3 Comments

  1.  
    JV ~ 16 months ago
    0 votes thumbs up thumbs down
    How does it work? What's it doing? Also, if you don't mind could you make this a public article :)
    [ reply ]
    1.  
      Big Al ~ 16 months ago
      0 votes thumbs up thumbs down
      Yay! I can read it now it's public!
      [ reply ]
      1.  
        bkramer ~ 16 months ago
        0 votes thumbs up thumbs down
        I updated the article.
        [ reply ]
        1.  
          22 votes thumbs up thumbs down
          This is my two cents...

             
          Hey you know AdGuy always gets the last word! ;)

        Please Login to Add Your Comment   ..or..  

        Replying to comment by