Welcome, Guest. Register Now!
   
Mark Forums Read Mark Forums Read Mark Forums Read


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-02-2008, 08:48 PM
Junior Member
 
Join Date: Feb 2008
Posts: 2
Default i want count rows

I show my code:

PHP Code:
class users extends Zend_Db_Table_Abstract
{
    protected 
$_name 'users';
    
    public function 
select() {
        return 
$this->getAdapter()->select(); 
    }
    
    public function 
countusers() {
        
$select $this->select();
        
$select->from($this->_name,'COUNT(id) AS num');
        
$row=$this->fetchRow($select);
        return 
$row->num;
    }

but then, i want countusers, I get:

Code:
Fatal error: Uncaught exception 'Zend_Db_Statement_Exception' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 10' in /home/banners/domains/vipuff.com/public_html/library/Zend/Db/Statement/Pdo.php:227 Stack trace: #0 /home/banners/domains/vipuff.com/public_html/library/Zend/Db/Statement.php(279): Zend_Db_Statement_Pdo->_execute(Array) #1 /home/banners/domains/vipuff.com/public_html/library/Zend/Db/Adapter/Abstract.php(396): Zend_Db_Statement->execute(Array) #2 /home/banners/domains/vipuff.com/public_html/library/Zend/Db/Adapter/Pdo/Abstract.php(206): Zend_Db_Adapter_Abstract->query(Object(Zend_Db_Select), Array) #3 /home/banners/domains/vipuff.com/public_html/library/Zend/Db/Table/Abstract.php(1104): Zend_Db_Adapter_Pdo_Abstract->query(Object(Zend_Db_Select)) #4 /home/banners/domains/vipuff.com/public_html/library/Zend/Db/Table/Abstract.php(1011): Zend_Db_Tab in /***/***/public_html/library/Zend/Db/Statement/Pdo.php on line 227
if i write echo $select in true place, and see query, who work in phpmyadmint, but no work in users->countusers();.

Any ideas?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-06-2008, 10:16 AM
Junior Member
 
Join Date: Feb 2008
Posts: 3
Default

try
Code:
    public function countusers() {
        $select = $this->select();
        $select->from($this->_name,'COUNT(*) AS num');
        return $this->fetchRow($select)->num;
    }
edit: oh, and you should have a look at How can I get the number of rows in a query?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-06-2008, 06:32 PM
Junior Member
 
Join Date: Feb 2008
Posts: 2
Default

I update prototype to 1.5.0 PR and my code work.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 04:26 AM.