zepernick / Codeigniter-DataTables

CodeIgniter Library For Ajax Server Side DataTables 1.10 >
MIT License
94 stars 95 forks source link

Support for GROUP BY #20

Open gastongr opened 8 years ago

gastongr commented 8 years ago

Hello, first of all thanks for the great library Zepernick, it's perfectly implemented and allows very clean and DRY code!!

Just wanted to ask if you have an idea on how to use GROUP BY with the library? When using an aggregate function, like SUM(), in select statements, MySQL requieres a GROUP BY clause otherwise it will aggregate the entire table instead of returning one row for each entry.

So i'm using appendToSelect like this in my model: public function appendToSelectStr() { return array( 'stock' => 'SUM(st.stock)' ); }

But don't know where to add the GROUP BY clause. Any help is appreciated!

Thanks again!