谁能帮我将此mysql查询转换为redbean查询?
SELECT category,sum(price) from transaction GROUP BY category.
谁能帮我将此mysql查询转换为redbean查询?
SELECT category,sum(price) from transaction GROUP BY category.
我们可以像这样使用
$results = R::getAll( 'SELECT category,sum(price) from transaction GROUP BY category' );
// $results is multidimensional array
更好的转换是:
$sql = "SELECT category, sum(price) FROM transaction GROUP BY category";
$transactions = R::getAll($sql);
你不需要转换任何东西。你只需写:
$transactions = R::get("SELECT category,sum(price) from transaction GROUP BY category");