Ordering a helper query
Ordering a helper query
nskwortsow
Posts: 120Questions: 0Answers: 0
Hi,
The code below does not work.
To populate a SELECT box, I want an alphabetically sorted list from tblRegions. The only functionality which I could find documented was the order method?
Kind regards,
Nathan
$out['tblRegions'] = $db
->select( 'tblRegions', 'RID as value, RName0 as label' )
->order('RName0')
->fetchAll();
The code below does not work.
To populate a SELECT box, I want an alphabetically sorted list from tblRegions. The only functionality which I could find documented was the order method?
Kind regards,
Nathan
$out['tblRegions'] = $db
->select( 'tblRegions', 'RID as value, RName0 as label' )
->order('RName0')
->fetchAll();
This discussion has been closed.
Replies
The `select` is just a short hand for quick queries. If you want something more that what `select` provides then you need to use the `Query` object which is fully documented here:
http://editor.datatables.net/docs/current/php/class-DataTables.Database.Query.html
For example:
[code]
$db
->query( 'select' )
->table( 'tblRegions' )
->get( 'RID as value', 'RName0 as label' )
->order( 'RName0 asc' )
->exec()
->fetchAll();
[/code]
Allan