Correct syntax and placemente of ->order( ) clause in dependent() script

Correct syntax and placemente of ->order( ) clause in dependent() script

GargiucnGargiucn Posts: 105Questions: 30Answers: 0

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
    ]   
] );

?>

Thanks,
Giuseppe

Replies

This discussion has been closed.