Perrin Harkins wrote:
> On Thu, Feb 14, 2008 at 3:30 PM, Ken Prows <[EMAIL PROTECTED]> wrote:
>   
>> I am trying to find a way to use MySQL's FOUND_ROWS() feature with Rose:
>>
>>  
>> http://dev.mysql.com/doc/refman/5.0/en/information-functions.html#function_found-rows
>>
>>  I am most interested in getting this to work with my Manager classes so
>>  that I do not have to do a second query to find the total count using
>>  the 'get_objects_count' method.
>>     
>
> Usually people want to do this because they're using LIMIT, but it
> turns out to be a bad idea.  It's usually faster to do a second COUNT
> query than to use LIMIT and FOUND_ROWS.
>
> Since you are not using LIMIT, I don't think you need SQL_CALC_FOUND_ROWS.
>
> "In the absence of the SQL_CALC_FOUND_ROWS  option in the most recent
> SELECT  statement, FOUND_ROWS()  returns the number of rows in the
> result set returned by that statement."
>
> Try calling FOUND_ROWS() without SQL_CALC_FOUND_ROWS and see if it
> works.  (Kind of seems like you should be able to get this from DBI in
> some way too, but I think $sth->rows only works for
> INSERT//UPDATE/DELETE.)
>
>   
Sorry, I forgot to include the limit arg in my example. I do use limit 
so that I can page the data. I need to know the total matches so that I 
can determine how many pages there are.

FOUND_ROWS() does not work without including SQL_CALC_FOUND_ROWS. If 
SQL_CALC_FOUND_ROWS
 is left out, FOUND_ROWS() simply returns whatever the limit is set to.





-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object

Reply via email to