How to add to an editor WHERE clause

How to add to an editor WHERE clause

webpointzwebpointz Posts: 126Questions: 30Answers: 4
edited August 2016 in Editor

I have the following code and it works fine, however, I need to add something extra to the WHERE clause, specifically, limit the query to include checking a date column only for entries that are "NULL".

Example: "AND kit_inventory_item_history_date_removed IS NULL"

How and/or where could I add this?

Editor::inst( $db, 'kit_inventory_items', 'kit_inventory_items_id' )
    ->fields(

                 Field::inst( 'kit_items.kit_items_name' ),
                 Field::inst( 'kit_inventory_items.kit_inventory_items_serial_number' ),
                 Field::inst( 'kit_inventory_items.kit_inventory_items_status_id' )
                       ->options( 'kit_inventory_items_status', 'kit_inventory_items_status_id', 'kit_inventory_items_status_status' )
                       ->validator( 'Validate::dbValues' ),
                 Field::inst( 'kit_inventory_items_status.kit_inventory_items_status_status' ),
                 Field::inst( 'kit_inventory_items.kit_inventory_items_id' )
    )

    ->leftJoin( 'kit_inventory_items_status', 'kit_inventory_items_status.kit_inventory_items_status_id', '=', 'kit_inventory_items.kit_inventory_items_status_id' )
    ->leftJoin( 'kit_items', 'kit_items.kit_items_id', '=', 'kit_inventory_items.kit_items_id' )
    ->leftJoin( 'kit_inventory_item_history', 'kit_inventory_item_history.kit_inventory_items_id', '=', 'kit_inventory_items.kit_inventory_items_id' )

    ->where( 'kit_inventory_item_history.kit_inventory_id', $_GET["thisinv"] )  
    
    ->process($_POST)
    ->json();

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin
    Answer ✓

    You should be able to add:

    ->where( 'kit_inventory_item_history.date_removed', null )
    

    on line 18.

    Allan

  • webpointzwebpointz Posts: 126Questions: 30Answers: 4

    Thanks Allan,

    I wasn't sure if i could put multiple where clauses but it works now.

This discussion has been closed.