0

I have a query to count all rows in Db table.

$results = $db->fetchAll('select count(id) as total_keys, sum(if(used,1,0)) as used_keys from product_keys');
$this->_helper->flashMessenger->addMessage($results);

I want to get the total_keys and used_keys, but it doesn't seen to work.

4

1 回答 1

2
$results = $db->fetchOne('select count(id) as total_keys, sum(if(used,1,0)) as used_keys from product_keys');
$this->_helper->flashMessenger->addMessage($results);
于 2013-02-14T18:01:05.693 回答