Need help understanding the Editor ->where() statement
Need help understanding the Editor ->where() statement

I'm fairly new with DataTables/Editor and need to understand how to get the 'where' configured in Editor. My SQL statement is conditioned on 1 of 3 variable passed in thru $_COOKIES.
My code:
$territory = $_COOKIE['territory'];
$category = $_COOKIE['category'];
$status = $_COOKIE['status'];
Editor::inst( $db, 'contacts', 'con_id' )
->fields(
Field::inst( 'territory' ),
Field::inst( 'postal' ),
Field::inst( 'house' ),
Field::inst( 'street' ),
Field::inst( 'first_name' ),
Field::inst( 'last_name' ),
Field::inst( 'phone' ),
Field::inst( 'mobile' ),
Field::inst( 'email' )
)
->where('territory', $territory) // $territory have a non-null value
->where('category', $category) // $category have a non-null value
->where('status', $status) // $status have a non-null value
->process( $_POST )
->json();
How could I declare the ->where() statements dynamically so that they are only included if the specified value is non-null?
For example I may only want the first one and the third one.
Thanks in advance
Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.
This question has an accepted answers - jump to answer
Answers
I believe you can group those conditions, see here.
So something like:
Colin