如何在zend中做这样的事情:
SELECT LEFT(log_browser, LOCATE(' ', log_browser)) AS browser, COUNT(*) AS amount
FROM logs
GROUP BY LEFT(log_browser, LOCATE(' ', log_browser))
如何在zend中做这样的事情:
SELECT LEFT(log_browser, LOCATE(' ', log_browser)) AS browser, COUNT(*) AS amount
FROM logs
GROUP BY LEFT(log_browser, LOCATE(' ', log_browser))
对表达式语句使用 Zend_Db_Expr 类:
$browserExpr = new Zend_Db_Expr('LEFT(log_browser, LOCATE(" ", log_browser))');
$select->from("logs", array('browser' => $browserExpr))->group($browserExpr);
尝试:$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
丁斯