$query = DB::select( 'auth_users.first_name', 'auth_users.last_name', ->from('auth_users') order_by('last_name'); ; $result = $query->execute(); $data = $result->as_array();
->order_by('last_name', 'first_name'); ->order_by('last_name, first_name'); ->order_by(array('last_name', 'first_name'));
Mitchell Steinberg wrote on Tuesday 24th of May 2011:I get database errors when I try to do an order_by by more than one column
This works for one column:$query = DB::select( 'auth_users.first_name', 'auth_users.last_name', ->from('auth_users') order_by('last_name'); ; $result = $query->execute(); $data = $result->as_array();
I've tried replacing the above order_by with the following and all give errors:->order_by('last_name', 'first_name'); ->order_by('last_name, first_name'); ->order_by(array('last_name', 'first_name'));
$result = DB::select('first_name', 'last_name')->from('auth_users')->order_by('first_name', 'asc')->order_by('last_name', 'asc')->as_object()->execute(); and then: foreach ($result as ... )
Then tell us the error, no way for us to help you if you don't let us know what's wrong. Copy past the exact text of the error message and don't interpret.I've tried replacing the above order_by with the following and all give errors:
It looks like you're new here. If you want to get involved, click one of these buttons!