Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 82439

Need help understanding the Editor ->where() statement

$
0
0

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


Viewing all articles
Browse latest Browse all 82439

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>