SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Wizard
    Join Date
    Feb 2009
    Posts
    1,005
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Zend_Db_Table_Abstract - Help on doing a SUM

    Hello all,

    I'm trying to do a SUM like so:
    PHP Code:
    $select $this->select('sum(pontos) as total')->from('desafios');
    $resultado $this->fetchRow($select);
    $total $resultado->total
    But I'm getting:
    Exception 'Zend_Db_Table_Row_Exception' with message 'Specified column "total" is not in the row

    so, is not assuming the AS...

    Tried:

    PHP Code:
    $select $this->select()->from('desafios', array('sum(pontos) as total'));
    $total $this->fetchRow($select);
    $total->total;
    var_dump($total); 
    and

    PHP Code:
    $select $this->select()->from('desafios', array('sum(pontos) as total'));
     
    $total $this->fetchRow($select);
     
    var_dump($total); 

    No luck either.

    Any help please?


    Thanks a lot,
    Márcio

  2. #2
    SitePoint Wizard
    Join Date
    Feb 2009
    Posts
    1,005
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Actually, the last to code examples worked ok.
    Spell-check issue.



    Regards,
    Márcio


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •