简体   繁体   中英

Zend Database get count

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.

$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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM