Using $Where on Class Datatables

Using $Where on Class Datatables

vincmeistervincmeister Posts: 136Questions: 36Answers: 4

Hello Allan, Happy New Year
Wish a better year for you

I want to use where with condition

->select( 
 'v_item_pr_po', 
 ['item_code as value', 'item_name as label'], 
 ['pr_no' => $_REQUEST['values']['prnumber'] ) **AND here**

I want to add q_po > 0
I tried some, but no luck, please advise

Regards,
Danny

This question has accepted answers - jump to:

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Answer ✓

    Is this the $db->select() method? It isn't clear from your question I'm afraid.

    You'll need to use $db->query() to do that and build up your own query.

    It might help to know that this is what the select() method does.

    Allan

  • vincmeistervincmeister Posts: 136Questions: 36Answers: 4

    yes Allan, $db->select() method
    This is my working example

    include_once( "../php/DataTables.php" );
     
    $cities = $db
        ->select( 'inp_master_cities', ['id as value', 'city as label'], ['province_code' => $_REQUEST['values']['province']] )
        ->fetchAll();
     
    echo json_encode( [
        'options' => [
            'city' => $cities
        ]
    ] );
    

    and I want to duplicate and add new condition AND item_code = $item_code to this

    ->select(
     'v_item_pr_po',
     ['item_code as value', 'item_name as label'],
     ['pr_no' => $_REQUEST['values']['prnumber'] ) **AND here**
    

    please advise, thank you

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    Did you try using the $db->query() method? Can you show me the code you used?

    Allan

  • vincmeistervincmeister Posts: 136Questions: 36Answers: 4
    edited January 2018 Answer ✓

    Hi Allan,

    I solved my problem by using this

    ->select( 'v_item_pr_po', ['item_code as value', 'item_name as label'], ['pr_no' => $_REQUEST['values']['prnumber'] , 'q_po' => '> 0' ] )
    

    thanks

This discussion has been closed.