0

如何在zend中做这样的事情:

SELECT LEFT(log_browser, LOCATE(' ', log_browser)) AS browser, COUNT(*) AS amount
FROM logs
GROUP BY LEFT(log_browser, LOCATE(' ', log_browser))
4

2 回答 2

0

对表达式语句使用 Zend_Db_Expr 类:

$browserExpr = new Zend_Db_Expr('LEFT(log_browser, LOCATE(" ", log_browser))');
$select->from("logs", array('browser' => $browserExpr))->group($browserExpr);
于 2012-11-16T07:14:25.220 回答
0

尝试:$select->from($name, $column)->group()

$select->from("logs", array("LEFT(log_browser, LOCATE(' ', log_browser))" => "browser" ,"count(*)" => "amount"))
       ->group(array("LEFT(log_browser, LOCATE(' ', log_browser)");

更多信息这是如何工作的 http://framework.zend.com/manual/1.12/en/zend.db.select.html#zend.db.select.building.group

丁斯

于 2012-11-15T02:57:18.547 回答