Correct syntax and placemente of ->order( ) clause in dependent() script
Correct syntax and placemente of ->order( ) clause in dependent() script
In dependent() script I need to use the ->order() clause but I would like an example for the correct placement and syntax.
```
<?php
include( "DataTables.php" );
$mesi = $db
->select( 'rlistini', ['rlist_id as value', "CONCAT(rlist_mesi, ' mesi [Fatturato da €',rlist_fmin,' a €',rlist_fmax,']') as label"],
function ( $q ) {
if ( $_REQUEST['values']['contratti.contr_clifatt'] > 0 ){
//se il campo fatturato del cliente è maggiore di zero
$q->where( 'rlist_idnome', $_REQUEST['values']['contratti.contr_tlistid'] )
->and_where( function ( $r ) {
$r->where( 'rlist_fmin', $_REQUEST['values']['contratti.contr_clifatt'], '<=' );
$r->where( 'rlist_fmax', $_REQUEST['values']['contratti.contr_clifatt'], '>=' );
} );
}else{
$q->where( 'rlist_idnome', $_REQUEST['values']['contratti.contr_tlistid'] );
}
} )
->order( 'rlist_idnome', 'ASC' ) //where do I put this instruction and what is the correct syntax?
->fetchAll();
echo json_encode( [
'options' => [
'contratti.contr_rlistid' => $mesi
]
] );
<?php > ``` Thanks, Giuseppe ?>This discussion has been closed.
Replies
Hi Giuseppe,
The
$db->select()
method returns aResult
object so there is noorder()
method available on it. Instead, what you need to do is use the optional fourth parameter which lets you pass in the ordering information.Regards,
Allan