Closed lucas-facchini closed 9 years ago
Hello i've added a sql function system.
You have now following native helpers:
// simple count
$table->select()->count();
// with special field
$table->select()->count('id');
// min value
$table->select()->min('views');
// max value
$table->select()->max('views');
// sum value
$table->select()->sum('views');
// avarage value
$table->select()->avg('views');
In more complex queries you can make use of the new field helpers:
$query->addFieldCount('id');
// with alias
$query->addFieldCount('id', 'total_count');
// max
$query->addFieldMax('views');
// min
$query->addFieldMin('views');
// sum
$query->addFieldSum('views');
// avarage
$query->addFieldAvg('views');
// rounding
$query->addFieldRound('price', 2, 'rounded_price');
See:
I have several statements that require the use of
COUNT
andSUM
in my project. Since the library parses my input, I have to use theraw(expression)
function which solves the problem, but it doesn't look good in the code.Edit: There's a function
count()
but it doesn't let you choose the column..