RE: [fw-general] CALC_FOUND_ROWS vs. count(*)
Hi Simon, Thanks for the thoughts, here's what I tried: $select = $this->db->select()->from( array( 'swatches' ), array( new Zend_Db_Expr('SQL_CALC_FOUND_ROWS '), 'swatch_id' => 'swatches.id', 'categories.category_name', 'collections.collection_name', 'patterns.pattern_name', 'pattern_types.pattern_type_name', 'color_categories.color_category_name', 'swatches.color') ); This is the sql statement: SELECT SQL_CALC_FOUND_ROWS , `swatches`.`id` AS `swatch_id`, `categories`.`category_name`, If you look closely it's sticking a comma in between SQL_CALC_FOUND_ROWS and the next column. Which will throw an error. Though looking at this I bet I could do something like New Zend_Db_expr( 'SQL_CALC_FOUND_ROWS swatches.id AS swatch_id'), then all the normal stuff seems like one way to get around it. Well that's a lot easier than trying to subclass . though I do like how much cleaner subclassing could be versus doing something like te above line . Mark _ From: Simon Mundy [mailto:[EMAIL PROTECTED] Sent: Thursday, April 17, 2008 8:50 PM To: Gunter Sammet Cc: Mark Steudel; Shekar C Reddy; James Dempster; fw-general@lists.zend.com Subject: Re: [fw-general] CALC_FOUND_ROWS vs. count(*) Hi Gunter Thanks for the clarification. The statement I used below will still work after a select() is executed:- $select->from('yourtable', new Zend_Db_Expr('SQL_CALC_FOUND_ROWS *'))->where('id > ?', 100)->limit(10); // SELECT SQL_CALC_FOUND_ROWS * FROM `yourtable` WHERE (id > 100) LIMIT 10 $select->from(null, new Zend_Db_Expr('FOUND_ROWS()')); // SELECT FOUND_ROWS() You won't need to subclass Zend_Db_Select to achieve this. The pagination feature request is something I see a lot of value in and it certainly hasn't been forgotten - the challenge is to work out how we can achieve this consistently for each adapter. Whilst I have a good grasp of SQLITE, MySQL and PgSQL I think there may be some help needed for the other flavours, such as DB2, Oracle, etc... Cheers Hi Simon: The reason to prepend CALC_FOUND_ROWS in MySQL is to be able to get the total number of rows for a statement if you restrict with a limit for pagination. Have a quick look at http://dev.mysql.com/doc/refman/5.1/en/information-functions.html#function_f ound-rows to see how it works. For pagination it would be nice having a way to determine the number of rows without the limit clause. Since Zend_Db handles multiple databases we would need an implementation for each flavor. As mentioned before, I suggested it before but didn't get much feedback on it. And I didn't have the time to work on it myself. Cheers, Gunter On Thu, Apr 17, 2008 at 9:01 PM, Simon Mundy <[EMAIL PROTECTED]> wrote: Hi Mark Do I understand correctly that you just needed to use that function as a returning field? If so, did the following not work for you? $select->from('yourtable', array('line_items_per_product' => new Zend_Db_Expr('CALC_FOUND_ROWS'))); Using a Zend_Db_Expr prevents a string from having further escaping applied to it. Cheers Well ... I played around with this and was able to hack up the Select class to put this functionality in. here it is if anyone is interested: http://www.mindfulinteractive.com/zend/Select.txt Basically you can now do something like $select->sqlCalcFoundRows(); And it will add 'SQL_CALC_FOUND_ROWS' at the beginning of the sql statement. I don't know what will happen if you do both distinct and sqlCalcFoundRows ... I'm now trying to see if I can subclass it, but I'm not a OOP Master. Here's my attempt, but I can't quite seem to override $_partsInit with my $_partsInit ... false, self::CALC_ROWS=> false, self::COLUMNS => array(), self::FROM => array(), self::WHERE=> array(), self::GROUP=> array(), self::HAVING => array(), self::ORDER=> array(), self::LIMIT_COUNT => null, self::LIMIT_OFFSET => null, self::FOR_UPDATE => false ); public function sqlCalcFoundRows( $flag = true ) { echo 'test'; $this->_parts[self::CALC_ROWS] = (bool) $flag; return $this; } protected function _renderSqlCalcFoundRows( $sql ) { if( $this->_parts[self::CALC_ROWS]) { $sql .= ' ' . self::SQL_CALC_ROWS ; } return $sql; } } MS -Original Message- From: Shekar C Reddy [mailto:[EMAIL PROTECTED] Sent: Thursday, April 17, 2008 1:41 PM To: Gunter Sammet Cc: Mark Steudel; James Dempster; fw-general@lists.zend.com
Re: [fw-general] CALC_FOUND_ROWS vs. count(*)
Hi Gunter Thanks for the clarification. The statement I used below will still work after a select() is executed:- $select->from('yourtable', new Zend_Db_Expr('SQL_CALC_FOUND_ROWS *'))- >where('id > ?', 100)->limit(10); // SELECT SQL_CALC_FOUND_ROWS * FROM `yourtable` WHERE (id > 100) LIMIT 10 $select->from(null, new Zend_Db_Expr('FOUND_ROWS()')); // SELECT FOUND_ROWS() You won't need to subclass Zend_Db_Select to achieve this. The pagination feature request is something I see a lot of value in and it certainly hasn't been forgotten - the challenge is to work out how we can achieve this consistently for each adapter. Whilst I have a good grasp of SQLITE, MySQL and PgSQL I think there may be some help needed for the other flavours, such as DB2, Oracle, etc... Cheers Hi Simon: The reason to prepend CALC_FOUND_ROWS in MySQL is to be able to get the total number of rows for a statement if you restrict with a limit for pagination. Have a quick look at http://dev.mysql.com/doc/refman/5.1/en/information-functions.html#function_found-rows to see how it works. For pagination it would be nice having a way to determine the number of rows without the limit clause. Since Zend_Db handles multiple databases we would need an implementation for each flavor. As mentioned before, I suggested it before but didn't get much feedback on it. And I didn't have the time to work on it myself. Cheers, Gunter On Thu, Apr 17, 2008 at 9:01 PM, Simon Mundy <[EMAIL PROTECTED]> wrote: Hi Mark Do I understand correctly that you just needed to use that function as a returning field? If so, did the following not work for you? $select->from('yourtable', array('line_items_per_product' => new Zend_Db_Expr('CALC_FOUND_ROWS'))); Using a Zend_Db_Expr prevents a string from having further escaping applied to it. Cheers Well ... I played around with this and was able to hack up the Select class to put this functionality in. here it is if anyone is interested: http://www.mindfulinteractive.com/zend/Select.txt Basically you can now do something like $select->sqlCalcFoundRows(); And it will add 'SQL_CALC_FOUND_ROWS' at the beginning of the sql statement. I don't know what will happen if you do both distinct and sqlCalcFoundRows ... I'm now trying to see if I can subclass it, but I'm not a OOP Master. Here's my attempt, but I can't quite seem to override $_partsInit with my $_partsInit ... * NOTE: It is important for the 'FOR_UPDATE' part to be last to ensure * meximum compatibility with database adapters. * * @var array */ protected static $_partsInit = array( self::DISTINCT => false, self::CALC_ROWS=> false, self::COLUMNS => array(), self::FROM => array(), self::WHERE=> array(), self::GROUP=> array(), self::HAVING => array(), self::ORDER=> array(), self::LIMIT_COUNT => null, self::LIMIT_OFFSET => null, self::FOR_UPDATE => false ); public function sqlCalcFoundRows( $flag = true ) { echo 'test'; $this->_parts[self::CALC_ROWS] = (bool) $flag; return $this; } protected function _renderSqlCalcFoundRows( $sql ) { if( $this->_parts[self::CALC_ROWS]) { $sql .= ' ' . self::SQL_CALC_ROWS ; } return $sql; } } MS -Original Message- From: Shekar C Reddy [mailto:[EMAIL PROTECTED] Sent: Thursday, April 17, 2008 1:41 PM To: Gunter Sammet Cc: Mark Steudel; James Dempster; fw-general@lists.zend.com Subject: Re: [fw-general] CALC_FOUND_ROWS vs. count(*) Creating a Jira issue would be ideal to keep a track of this task. On Thu, Apr 17, 2008 at 3:21 PM, Gunter Sammet <[EMAIL PROTECTED] > wrote: I ended up retrieving the SQL as string and do a string replace and then execute the SQL statement. Not very elegant but it solved my problem at that time. If you come up with a more elegant way, please let me know. Once I have time I'd like to add this as a functionality to the select class to allow for an DB independant way of doing this. I remember that I asked in the forum before and at that time it didn't seem to be very much required and for that reason didn't have much importance. HTH Gunter On Thu, Apr 17, 2008 at 2:07 PM, Mark Steudel <[EMAIL PROTECTED]> wrote: Well couple of problems, I can't mix a count() statement in my sql statement the whole mixing group columns with non group columns thing Even if I try and trick it by putting at the begging the select methods quote everything, so it because something like: SELECT `SQL_CALC_FOUND_ROWS table`.`id` .. :/ Any other ideas?
Re: [fw-general] CALC_FOUND_ROWS vs. count(*)
Hi Simon: The reason to prepend CALC_FOUND_ROWS in MySQL is to be able to get the total number of rows for a statement if you restrict with a limit for pagination. Have a quick look at http://dev.mysql.com/doc/refman/5.1/en/information-functions.html#function_found-rows to see how it works. For pagination it would be nice having a way to determine the number of rows without the limit clause. Since Zend_Db handles multiple databases we would need an implementation for each flavor. As mentioned before, I suggested it before but didn't get much feedback on it. And I didn't have the time to work on it myself. Cheers, Gunter On Thu, Apr 17, 2008 at 9:01 PM, Simon Mundy <[EMAIL PROTECTED]> wrote: > Hi Mark > > Do I understand correctly that you just needed to use that function as a > returning field? > > If so, did the following not work for you? > > $select->from('yourtable', array('line_items_per_product' => new > Zend_Db_Expr('CALC_FOUND_ROWS'))); > > Using a Zend_Db_Expr prevents a string from having further escaping > applied to it. > > Cheers > > > Well ... I played around with this and was able to hack up the Select > > class > > to put this functionality in. here it is if anyone is interested: > > > > http://www.mindfulinteractive.com/zend/Select.txt > > > > Basically you can now do something like > > > > $select->sqlCalcFoundRows(); > > > > And it will add 'SQL_CALC_FOUND_ROWS' at the beginning of the sql > > statement. > > I don't know what will happen if you do both distinct and > > sqlCalcFoundRows > > ... > > > > I'm now trying to see if I can subclass it, but I'm not a OOP Master. > > Here's > > my attempt, but I can't quite seem to override $_partsInit with my > > $_partsInit ... > > > > > > > class NewSelect extends Zend_Db_Select { > >const CALC_ROWS = 'sqlCalcFoundRows'; > >const SQL_CALC_ROWS = 'SQL_CALC_FOUND_ROWS'; > > > >/** > >* The initial values for the $_parts array. > >* NOTE: It is important for the 'FOR_UPDATE' part to be last to > > ensure > >* meximum compatibility with database adapters. > >* > >* @var array > >*/ > > protected static $_partsInit = array( > > self::DISTINCT => false, > > self::CALC_ROWS=> false, > > self::COLUMNS => array(), > > self::FROM => array(), > > self::WHERE=> array(), > > self::GROUP=> array(), > > self::HAVING => array(), > > self::ORDER=> array(), > > self::LIMIT_COUNT => null, > > self::LIMIT_OFFSET => null, > > self::FOR_UPDATE => false > > ); > > > >public function sqlCalcFoundRows( $flag = true ) > > { > >echo 'test'; > >$this->_parts[self::CALC_ROWS] = (bool) $flag; > >return $this; > > } > > > >protected function _renderSqlCalcFoundRows( $sql ) > > { > >if( $this->_parts[self::CALC_ROWS]) { > >$sql .= ' ' . self::SQL_CALC_ROWS ; > >} > > > >return $sql; > > } > > } > > > > MS > > -Original Message- > > From: Shekar C Reddy [mailto:[EMAIL PROTECTED] > > Sent: Thursday, April 17, 2008 1:41 PM > > To: Gunter Sammet > > Cc: Mark Steudel; James Dempster; fw-general@lists.zend.com > > Subject: Re: [fw-general] CALC_FOUND_ROWS vs. count(*) > > > > Creating a Jira issue would be ideal to keep a track of this task. > > > > > > > > On Thu, Apr 17, 2008 at 3:21 PM, Gunter Sammet <[EMAIL PROTECTED]> > > wrote: > > > > > I ended up retrieving the SQL as string and do a string replace and > > > then > > > execute the SQL statement. Not very elegant but it solved my problem > > > at > > > > > that > > > > > time. If you come up with a more elegant way, please let me know. > > > Once I have time I'd like to add this as a functionality to the select > > > > > class > > > > > to allow for an DB independant way of doing this. I remember that I > > > asked > > > > > in > > > > > the forum before and at that time it didn't seem to be very much > > > required > > > and for that reason didn't have much importance.
Re: [fw-general] CALC_FOUND_ROWS vs. count(*)
Hi Mark Do I understand correctly that you just needed to use that function as a returning field? If so, did the following not work for you? $select->from('yourtable', array('line_items_per_product' => new Zend_Db_Expr('CALC_FOUND_ROWS'))); Using a Zend_Db_Expr prevents a string from having further escaping applied to it. Cheers Well ... I played around with this and was able to hack up the Select class to put this functionality in. here it is if anyone is interested: http://www.mindfulinteractive.com/zend/Select.txt Basically you can now do something like $select->sqlCalcFoundRows(); And it will add 'SQL_CALC_FOUND_ROWS' at the beginning of the sql statement. I don't know what will happen if you do both distinct and sqlCalcFoundRows ... I'm now trying to see if I can subclass it, but I'm not a OOP Master. Here's my attempt, but I can't quite seem to override $_partsInit with my $_partsInit ... * NOTE: It is important for the 'FOR_UPDATE' part to be last to ensure * meximum compatibility with database adapters. * * @var array */ protected static $_partsInit = array( self::DISTINCT => false, self::CALC_ROWS=> false, self::COLUMNS => array(), self::FROM => array(), self::WHERE=> array(), self::GROUP=> array(), self::HAVING => array(), self::ORDER=> array(), self::LIMIT_COUNT => null, self::LIMIT_OFFSET => null, self::FOR_UPDATE => false ); public function sqlCalcFoundRows( $flag = true ) { echo 'test'; $this->_parts[self::CALC_ROWS] = (bool) $flag; return $this; } protected function _renderSqlCalcFoundRows( $sql ) { if( $this->_parts[self::CALC_ROWS]) { $sql .= ' ' . self::SQL_CALC_ROWS ; } return $sql; } } MS -Original Message- From: Shekar C Reddy [mailto:[EMAIL PROTECTED] Sent: Thursday, April 17, 2008 1:41 PM To: Gunter Sammet Cc: Mark Steudel; James Dempster; fw-general@lists.zend.com Subject: Re: [fw-general] CALC_FOUND_ROWS vs. count(*) Creating a Jira issue would be ideal to keep a track of this task. On Thu, Apr 17, 2008 at 3:21 PM, Gunter Sammet <[EMAIL PROTECTED] > wrote: I ended up retrieving the SQL as string and do a string replace and then execute the SQL statement. Not very elegant but it solved my problem at that time. If you come up with a more elegant way, please let me know. Once I have time I'd like to add this as a functionality to the select class to allow for an DB independant way of doing this. I remember that I asked in the forum before and at that time it didn't seem to be very much required and for that reason didn't have much importance. HTH Gunter On Thu, Apr 17, 2008 at 2:07 PM, Mark Steudel <[EMAIL PROTECTED]> wrote: Well couple of problems, I can't mix a count() statement in my sql statement the whole mixing group columns with non group columns thing Even if I try and trick it by putting at the begging the select methods quote everything, so it because something like: SELECT `SQL_CALC_FOUND_ROWS table`.`id` .. :/ Any other ideas? MS ____________ From: James Dempster [mailto:[EMAIL PROTECTED] Sent: Thursday, April 17, 2008 12:48 PM To: Mark Steudel Cc: fw-general@lists.zend.com Subject: Re: [fw-general] CALC_FOUND_ROWS vs. count(*) Have you tried array('line_items_per_product' => 'CALC_FOUND_ROWS COUNT(*)')) I think that might work. -- /James On Thu, Apr 17, 2008 at 8:06 PM, Mark Steudel <[EMAIL PROTECTED]> wrote: Hey Guys, I was looking for a way to use CALC_FOUND_ROWS in mysql, I saw in the documentation you could get the same thing by doing this: array('line_items_per_product' => 'COUNT(*)')) If I wanted to do CALC_FOUND_ROWS instead, how would I do it utilizing the Zend_DB? Thanks, Mark -- Simon Mundy | Director | PEPTOLAB """ " "" """""" "" "" """"""" " "" """"" " """"" " """""" "" " 202/258 Flinders Lane | Melbourne | Victoria | Australia | 3000 Voice +61 (0) 3 9654 4324 | Mobile 0438 046 061 | Fax +61 (0) 3 9654 4124 http://www.peptolab.com
RE: [fw-general] CALC_FOUND_ROWS vs. count(*)
Well ... I played around with this and was able to hack up the Select class to put this functionality in. here it is if anyone is interested: http://www.mindfulinteractive.com/zend/Select.txt Basically you can now do something like $select->sqlCalcFoundRows(); And it will add 'SQL_CALC_FOUND_ROWS' at the beginning of the sql statement. I don't know what will happen if you do both distinct and sqlCalcFoundRows ... I'm now trying to see if I can subclass it, but I'm not a OOP Master. Here's my attempt, but I can't quite seem to override $_partsInit with my $_partsInit ... false, self::CALC_ROWS=> false, self::COLUMNS => array(), self::FROM => array(), self::WHERE=> array(), self::GROUP=> array(), self::HAVING => array(), self::ORDER=> array(), self::LIMIT_COUNT => null, self::LIMIT_OFFSET => null, self::FOR_UPDATE => false ); public function sqlCalcFoundRows( $flag = true ) { echo 'test'; $this->_parts[self::CALC_ROWS] = (bool) $flag; return $this; } protected function _renderSqlCalcFoundRows( $sql ) { if( $this->_parts[self::CALC_ROWS]) { $sql .= ' ' . self::SQL_CALC_ROWS ; } return $sql; } } MS -Original Message- From: Shekar C Reddy [mailto:[EMAIL PROTECTED] Sent: Thursday, April 17, 2008 1:41 PM To: Gunter Sammet Cc: Mark Steudel; James Dempster; fw-general@lists.zend.com Subject: Re: [fw-general] CALC_FOUND_ROWS vs. count(*) Creating a Jira issue would be ideal to keep a track of this task. On Thu, Apr 17, 2008 at 3:21 PM, Gunter Sammet <[EMAIL PROTECTED]> wrote: > I ended up retrieving the SQL as string and do a string replace and then > execute the SQL statement. Not very elegant but it solved my problem at that > time. If you come up with a more elegant way, please let me know. > Once I have time I'd like to add this as a functionality to the select class > to allow for an DB independant way of doing this. I remember that I asked in > the forum before and at that time it didn't seem to be very much required > and for that reason didn't have much importance. > HTH > > Gunter > > > > On Thu, Apr 17, 2008 at 2:07 PM, Mark Steudel <[EMAIL PROTECTED]> wrote: > > > > > > > > > > > Well couple of problems, > > > > > > > > I can't mix a count() statement in my sql statement the whole mixing group > columns with non group columns thing > > Even if I try and trick it by putting at the begging the select methods > quote everything, so it because something like: > > > > SELECT `SQL_CALC_FOUND_ROWS table`.`id` .. > > > > > > > > :/ Any other ideas? > > > > > > > > MS > > > > > > > > > > > > > From: James Dempster [mailto:[EMAIL PROTECTED] > > Sent: Thursday, April 17, 2008 12:48 PM > > To: Mark Steudel > > Cc: fw-general@lists.zend.com > > Subject: Re: [fw-general] CALC_FOUND_ROWS vs. count(*) > > > > > > > > > > > > > > Have you tried > > > > array('line_items_per_product' => 'CALC_FOUND_ROWS COUNT(*)')) > > > > I think that might work. > > > > -- > > /James > > > > > > On Thu, Apr 17, 2008 at 8:06 PM, Mark Steudel <[EMAIL PROTECTED]> wrote: > > > > > > > > Hey Guys, > > > > > > > > I was looking for a way to use CALC_FOUND_ROWS in mysql, I saw in the > documentation you could get the same thing by doing this: > > > > array('line_items_per_product' => 'COUNT(*)')) > > > > > > > > > > If I wanted to do CALC_FOUND_ROWS instead, how would I do it utilizing the > Zend_DB? > > > > > > > > Thanks, Mark > > > > > > > > > >
Re: [fw-general] CALC_FOUND_ROWS vs. count(*)
Creating a Jira issue would be ideal to keep a track of this task. On Thu, Apr 17, 2008 at 3:21 PM, Gunter Sammet <[EMAIL PROTECTED]> wrote: > I ended up retrieving the SQL as string and do a string replace and then > execute the SQL statement. Not very elegant but it solved my problem at that > time. If you come up with a more elegant way, please let me know. > Once I have time I'd like to add this as a functionality to the select class > to allow for an DB independant way of doing this. I remember that I asked in > the forum before and at that time it didn't seem to be very much required > and for that reason didn't have much importance. > HTH > > Gunter > > > > On Thu, Apr 17, 2008 at 2:07 PM, Mark Steudel <[EMAIL PROTECTED]> wrote: > > > > > > > > > > > Well couple of problems, > > > > > > > > I can't mix a count() statement in my sql statement the whole mixing group > columns with non group columns thing > > Even if I try and trick it by putting at the begging the select methods > quote everything, so it because something like: > > > > SELECT `SQL_CALC_FOUND_ROWS table`.`id` …. > > > > > > > > :/ Any other ideas? > > > > > > > > MS > > > > > > > > ____________ > > > > > From: James Dempster [mailto:[EMAIL PROTECTED] > > Sent: Thursday, April 17, 2008 12:48 PM > > To: Mark Steudel > > Cc: fw-general@lists.zend.com > > Subject: Re: [fw-general] CALC_FOUND_ROWS vs. count(*) > > > > > > > > > > > > > > Have you tried > > > > array('line_items_per_product' => 'CALC_FOUND_ROWS COUNT(*)')) > > > > I think that might work. > > > > -- > > /James > > > > > > On Thu, Apr 17, 2008 at 8:06 PM, Mark Steudel <[EMAIL PROTECTED]> wrote: > > > > > > > > Hey Guys, > > > > > > > > I was looking for a way to use CALC_FOUND_ROWS in mysql, I saw in the > documentation you could get the same thing by doing this: > > > > array('line_items_per_product' => 'COUNT(*)')) > > > > > > > > > > If I wanted to do CALC_FOUND_ROWS instead, how would I do it utilizing the > Zend_DB? > > > > > > > > Thanks, Mark > > > > > > > > > >
RE: [fw-general] CALC_FOUND_ROWS vs. count(*)
Yah . will give it a go . _ From: James Dempster [mailto:[EMAIL PROTECTED] Sent: Thursday, April 17, 2008 1:20 PM To: Mark Steudel Cc: fw-general@lists.zend.com Subject: Re: [fw-general] CALC_FOUND_ROWS vs. count(*) yeah looks like a tricky one, you could always extend the Zend_Db_Select class and implement your own CALC_FOUND_ROWS follow the DISTINCT as an example I think. -- /James On Thu, Apr 17, 2008 at 9:13 PM, Mark Steudel <[EMAIL PROTECTED]> wrote: Unless things have changed since 2007 I can't use the SQL_CALC_FOUND_ROWS with the select methods . bummer. _ From: James Dempster [mailto:[EMAIL PROTECTED] Sent: Thursday, April 17, 2008 12:48 PM To: Mark Steudel Cc: fw-general@lists.zend.com Subject: Re: [fw-general] CALC_FOUND_ROWS vs. count(*) Have you tried array('line_items_per_product' => 'CALC_FOUND_ROWS COUNT(*)')) I think that might work. -- /James On Thu, Apr 17, 2008 at 8:06 PM, Mark Steudel <[EMAIL PROTECTED]> wrote: Hey Guys, I was looking for a way to use CALC_FOUND_ROWS in mysql, I saw in the documentation you could get the same thing by doing this: array('line_items_per_product' => 'COUNT(*)')) If I wanted to do CALC_FOUND_ROWS instead, how would I do it utilizing the Zend_DB? Thanks, Mark
Re: [fw-general] CALC_FOUND_ROWS vs. count(*)
I ended up retrieving the SQL as string and do a string replace and then execute the SQL statement. Not very elegant but it solved my problem at that time. If you come up with a more elegant way, please let me know. Once I have time I'd like to add this as a functionality to the select class to allow for an DB independant way of doing this. I remember that I asked in the forum before and at that time it didn't seem to be very much required and for that reason didn't have much importance. HTH Gunter On Thu, Apr 17, 2008 at 2:07 PM, Mark Steudel <[EMAIL PROTECTED]> wrote: > Well couple of problems, > > > >1. I can't mix a count() statement in my sql statement the whole >mixing group columns with non group columns thing >2. Even if I try and trick it by putting at the begging the select >methods quote everything, so it because something like: > >SELECT `SQL_CALC_FOUND_ROWS table`.`id` …. > > > > :/ Any other ideas? > > > > MS > > > -- > > *From:* James Dempster [mailto:[EMAIL PROTECTED] > *Sent:* Thursday, April 17, 2008 12:48 PM > *To:* Mark Steudel > *Cc:* fw-general@lists.zend.com > *Subject:* Re: [fw-general] CALC_FOUND_ROWS vs. count(*) > > > > Have you tried > > array('line_items_per_product' => 'CALC_FOUND_ROWS COUNT(*)')) > > I think that might work. > > -- > /James > > On Thu, Apr 17, 2008 at 8:06 PM, Mark Steudel <[EMAIL PROTECTED]> wrote: > > Hey Guys, > > > > I was looking for a way to use CALC_FOUND_ROWS in mysql, I saw in the > documentation you could get the same thing by doing this: > > > > array('line_items_per_product' => 'COUNT(*)')) > > > > If I wanted to do CALC_FOUND_ROWS instead, how would I do it utilizing the > Zend_DB? > > > > Thanks, Mark > > > > >
Re: [fw-general] CALC_FOUND_ROWS vs. count(*)
yeah looks like a tricky one, you could always extend the Zend_Db_Select class and implement your own CALC_FOUND_ROWS follow the DISTINCT as an example I think. -- /James On Thu, Apr 17, 2008 at 9:13 PM, Mark Steudel <[EMAIL PROTECTED]> wrote: > Unless things have changed since 2007 I can't use the SQL_CALC_FOUND_ROWS > with the select methods … bummer. > > > -- > > *From:* James Dempster [mailto:[EMAIL PROTECTED] > *Sent:* Thursday, April 17, 2008 12:48 PM > *To:* Mark Steudel > *Cc:* fw-general@lists.zend.com > *Subject:* Re: [fw-general] CALC_FOUND_ROWS vs. count(*) > > > > Have you tried > > array('line_items_per_product' => 'CALC_FOUND_ROWS COUNT(*)')) > > I think that might work. > > -- > /James > > On Thu, Apr 17, 2008 at 8:06 PM, Mark Steudel <[EMAIL PROTECTED]> wrote: > > Hey Guys, > > > > I was looking for a way to use CALC_FOUND_ROWS in mysql, I saw in the > documentation you could get the same thing by doing this: > > > > array('line_items_per_product' => 'COUNT(*)')) > > > > If I wanted to do CALC_FOUND_ROWS instead, how would I do it utilizing the > Zend_DB? > > > > Thanks, Mark > > > > >
RE: [fw-general] CALC_FOUND_ROWS vs. count(*)
Unless things have changed since 2007 I can't use the SQL_CALC_FOUND_ROWS with the select methods . bummer. _ From: James Dempster [mailto:[EMAIL PROTECTED] Sent: Thursday, April 17, 2008 12:48 PM To: Mark Steudel Cc: fw-general@lists.zend.com Subject: Re: [fw-general] CALC_FOUND_ROWS vs. count(*) Have you tried array('line_items_per_product' => 'CALC_FOUND_ROWS COUNT(*)')) I think that might work. -- /James On Thu, Apr 17, 2008 at 8:06 PM, Mark Steudel <[EMAIL PROTECTED]> wrote: Hey Guys, I was looking for a way to use CALC_FOUND_ROWS in mysql, I saw in the documentation you could get the same thing by doing this: array('line_items_per_product' => 'COUNT(*)')) If I wanted to do CALC_FOUND_ROWS instead, how would I do it utilizing the Zend_DB? Thanks, Mark
RE: [fw-general] CALC_FOUND_ROWS vs. count(*)
Well couple of problems, 1. I can't mix a count() statement in my sql statement the whole mixing group columns with non group columns thing 2. Even if I try and trick it by putting at the begging the select methods quote everything, so it because something like: SELECT `SQL_CALC_FOUND_ROWS table`.`id` .. :/ Any other ideas? MS _ From: James Dempster [mailto:[EMAIL PROTECTED] Sent: Thursday, April 17, 2008 12:48 PM To: Mark Steudel Cc: fw-general@lists.zend.com Subject: Re: [fw-general] CALC_FOUND_ROWS vs. count(*) Have you tried array('line_items_per_product' => 'CALC_FOUND_ROWS COUNT(*)')) I think that might work. -- /James On Thu, Apr 17, 2008 at 8:06 PM, Mark Steudel <[EMAIL PROTECTED]> wrote: Hey Guys, I was looking for a way to use CALC_FOUND_ROWS in mysql, I saw in the documentation you could get the same thing by doing this: array('line_items_per_product' => 'COUNT(*)')) If I wanted to do CALC_FOUND_ROWS instead, how would I do it utilizing the Zend_DB? Thanks, Mark
Re: [fw-general] CALC_FOUND_ROWS vs. count(*)
Have you tried array('line_items_per_product' => 'CALC_FOUND_ROWS COUNT(*)')) I think that might work. -- /James On Thu, Apr 17, 2008 at 8:06 PM, Mark Steudel <[EMAIL PROTECTED]> wrote: > Hey Guys, > > > > I was looking for a way to use CALC_FOUND_ROWS in mysql, I saw in the > documentation you could get the same thing by doing this: > > > > array('line_items_per_product' => 'COUNT(*)')) > > > > If I wanted to do CALC_FOUND_ROWS instead, how would I do it utilizing the > Zend_DB? > > > > Thanks, Mark > > >
[fw-general] CALC_FOUND_ROWS vs. count(*)
Hey Guys, I was looking for a way to use CALC_FOUND_ROWS in mysql, I saw in the documentation you could get the same thing by doing this: array('line_items_per_product' => 'COUNT(*)')) If I wanted to do CALC_FOUND_ROWS instead, how would I do it utilizing the Zend_DB? Thanks, Mark