Why aren't you aliasing Count(*) to a col. Name?

Also, if you're using mysql - you may want to take a look at this:
http://www.mysqlperformanceblog.com/2007/04/10/count-vs-countcol/

Discusses Count(*) vs Count(col-name), and some caveats and performance
issues.


 
--
Eric Marden



-----Original Message-----
From: Sergei Izvorean [mailto:[EMAIL PROTECTED] 
Sent: Monday, April 07, 2008 2:39 PM
To: [email protected]
Subject: [fw-general] Zend_Db_Select bug

When I'm trying to select 'COUNT(*)' I get this error:
*Notice*: Object of class Zend_Db_Expr could not be converted to int in
/*Zend/Db/Table/Select.php* on line *125

*To reproduce:
$accountTable = new Account();
$accountTable->select()->from(array('a' => $accountTable->info('name')),
array('COUNT(*)')); or $accountTable->select()->from(array('a' =>
$accountTable->info('name')), array(new Zend_Db_Expr('COUNT(*)')));

I get same Notice with both versions of code.


Possible solution:
In Zend_Db_Select change:

            switch (true) {
                case ($column == self::SQL_WILDCARD):
                    break;

                case ($column instanceof Zend_Db_Expr):
                case (!in_array($column, $cols)):
                    $readOnly = true;
                    break 2;
            }

to:

            switch (true) {
                case ($column instanceof Zend_Db_Expr):
                case (!in_array($column, $cols)):
                    $readOnly = true;
                    break 2;

                case ($column == self::SQL_WILDCARD):
                    break;
            }

--
Sergei Izvorean
Web Developer

2440 Media Inc
401 Wood St., Suite 902
Pittsburgh, PA 15222
[t] 1-888-WEB-2440
[f] 1-877-FAX-2440
www.2440Media.com

Reply via email to