Zend Framework how to echo value of SUM query

Posted by Rick de Graaf on Stack Overflow See other posts from Stack Overflow or by Rick de Graaf
Published on 2010-04-15T09:31:48Z Indexed on 2010/04/15 12:13 UTC
Read the original article Hit count: 457

Filed under:
|
|
|

Hello,

I created a query for the zend framework, in which I try to retrieve the sum of a column, in this case the column named 'time'. This is the query I use:

$this->timequery = $this->db_tasks->fetchAll($this->db_tasks->select()->from('tasks', 'SUM(time)')->where('projectnumber =' . $this->value_project));


$this->view->sumtime = $this->timequery;

Echoing the query tells me this is right. But I can't echo the result properly. Currently I'm using:

echo $this->sumtime['SUM(time)'];

Returning the following error:

Catchable fatal error: Object of class Zend_Db_Table_Row could not be converted to string in C:\xampp\htdocs\BManagement\application\views\scripts\tasks\index.phtml  on line 46

Line 46 being the line with the echo in my view.

I've been searching now for two days on how to figure this out, or achieve the same result in a different way. Tried to serialize the value, but that didn't work either.

Is there somebody who knows how to achieve the total sum of a database column?

Any help is greatly appriciated!

note: Pretty new to zend framework...

© Stack Overflow or respective owner

Related posts about zend

Related posts about framework