Close   

Admin and announcement forums

    30 Mar 2008
Getting result count and limited results in single query  
kumar rakesh
create and manage free online surveys with unlimited responses
Online surveys are now basic requirement of everyone who want to review there products or to make studies about anything. But finding a solution who can provide esurveys efficiently is really a big pain. creating an online survey with inefficient tool as irritating and getting survey conducted with limitations on responses is even worse.
cont..
    30 Mar 2008
Getting result count and limited results in single query  
kumar rakesh
practice interviews and prepare for interviews
in todays changing world every one want to increase there salaries very quickly.
Changes your employer is an very efficient solution for this. But changing employer and company is not so easy.

cont..

Viewed 166 times
Total posts : 0

    20 Nov 2007
Getting result count and limited results in single query  
Riya Ila
His other forums
Getting result count and limited results in single query

How to determine the number of rows in the full result set and also restrict the
number of rows that a query returns,without running a second query ?



It's quite easy solution.

More of the programmers run 2 queries for this.
one to get total no. of results without limit and
second to get actual records with limits.

You can do it in a single query by using

SQL_CALC_FOUND_ROWS and
FOUND_ROWS()



Here SQL_CALC_FOUND_ROWS  will collect no. of results with limit and also fetches your real records with limit.
and  FOUND_ROWS() will return no. of records found.

you can use this in following way

<?php
  $q = sprintf("select SQL_CALC_FOUND_ROWS * from %smembers limit 10",DB_PREFIX);
  $r = $obj_class -> db -> sql_query($q);
  $q = "SELECT FOUND_ROWS() as count";
  $r = $obj_class -> db -> sql_query($q);
  echo "total no. of records :: ".$r['count'];
?>
Getting result count and limited results in single query Getting result count and limited results in single query
Getting result count and limited results in single query Be first to reply this discussion.
Getting result count and limited results in single query Getting result count and limited results in single query Getting result count and limited results in single query

Login to participate in forums
jump to :
Post reply on this forum

Jourgenz 27 Mar 2008

Hi.
It's test. This site was probably down...

riya ila 02 May 2008

hi jourgenz,
I never saw this site down !!!

Comment on this forum
Name :
Email :
Comments :
Legends
Getting result count and limited results in single query Forums tagged Getting result count and limited results in single query Forums tagged. But locked for further reply
="Getting Forums locked. can not accept further replies Getting result count and limited results in single query General forum