Pergunta

I have a question regarding zend db. I would like to select all the data from a table + an expression such as a count.

Unfortunately, when you pass an array with count in the select object, it will only select the count. As the table is really big, i prefer not to list all the columns in the table for the select.

Do you have any idea?

Foi útil?

Solução

You should add a group by to your select object. This makes sense because the aggregate functions are used in conjunction with the GROUP BY statement.

$select = $db->select();
$select->from(array('p' => 'product'), array('product_id','title', 'count(*)'));
$select->group('title');
$products = $db->fetchAll($select);
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top