[fw-general] SQL_CALC_FOUND_ROWS with Zend_Db_Select

2009-01-26 Thread Colin Guthrie

Hi,

Is there a way to inject this into SELECT statements?

This is typically very useful when paging and getting the correct number 
of results without having to re-run the query twice once with and once 
without the LIMIT/OFFSET components.


e.g. SELECT SQL_CALC_FOUND_ROWS * from blah LIMIT 10 OFFSET 10;

then SELECT FOUND_ROWS();



If this is something that would be accepted into ZF upstream, then I'll 
happily code it. It's more or less the same as $select-distinct($flag) 
function call. The select found rows things could be left to the user.


So, I'm just asking if this would be accepted? If not I'll try and work 
out another way of achieving the same result without hacking ZF.


Col



--

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
  Mandriva Linux Contributor [http://www.mandriva.com/]
  PulseAudio Hacker [http://www.pulseaudio.org/]
  Trac Hacker [http://trac.edgewall.org/]



Re: [fw-general] SQL_CALC_FOUND_ROWS with Zend_Db_Select

2009-01-26 Thread Dennis Becker
This is slower in comparison with a 2nd SELCT COUNT(PRIMARY_KEY_COLUMN)
FROM blah - look at
http://www.mysqlperformanceblog.com/2007/08/28/to-sql_calc_found_rows-or-not-to-sql_calc_found_rows/

Regards,
Dennis

On Mon, Jan 26, 2009 at 11:12 AM, Colin Guthrie gm...@colin.guthr.iewrote:

 Hi,

 Is there a way to inject this into SELECT statements?

 This is typically very useful when paging and getting the correct number of
 results without having to re-run the query twice once with and once without
 the LIMIT/OFFSET components.

 e.g. SELECT SQL_CALC_FOUND_ROWS * from blah LIMIT 10 OFFSET 10;

 then SELECT FOUND_ROWS();



 If this is something that would be accepted into ZF upstream, then I'll
 happily code it. It's more or less the same as $select-distinct($flag)
 function call. The select found rows things could be left to the user.

 So, I'm just asking if this would be accepted? If not I'll try and work out
 another way of achieving the same result without hacking ZF.

 Col



 --

 Colin Guthrie
 gmane(at)colin.guthr.ie
 http://colin.guthr.ie/

 Day Job:
  Tribalogic Limited [http://www.tribalogic.net/]
 Open Source:
  Mandriva Linux Contributor [http://www.mandriva.com/]
  PulseAudio Hacker [http://www.pulseaudio.org/]
  Trac Hacker [http://trac.edgewall.org/]




-- 
Dennis Becker   bec...@sipgate.de
Telefon:+49 (0) 211-63 55 55-97
Telefax:+49 (0) 211-63 55 55-22

sipgate GmbH - Gladbacher Str. 74 - 40219 Düsseldorf
HRB Düsseldorf 39841 - Geschäftsführer: Thilo Salmon, Tim Mois
Steuernummer: 106/5724/7147, Umsatzsteuer-ID: DE219349391

www.sipgate.de - www.sipgate.at - www.sipgate.co.uk