Editor with WHERE-clause Server-Side PHP table
Editor with WHERE-clause Server-Side PHP table
Hi,
I am trying to add a where-clause to my left Join query.
Editing the table.example.php
Eample:
...
Editor::inst( $db, 'example')
->fields(
Field::inst( 'table.column' )
->options( Options::inst()
->table( 'table2' )
->value( 'cloumn1' )
->label( 'label name' )
)
->validator( Validate::dbValues() ),
Field::inst( 'table1.column2' ),
Field::inst( 'table1.cloumn3' ),
...
)
->leftJoin( 'table2', 'table2.column1', '=', 'table1.column1' )
->where( 'table2.Active', 'Y')
->process( $_POST )
->json();
WHERE condition;
**Examples: **
Only provide the locations that are active. "Active" is the column and the values are "Y" and "No"
I keep getting the values in the dropdown selection. I would like to view the locations where locations = "Y" in the dropdown selection.
Thanks for all your help!
This question has an accepted answers - jump to answer
Answers
With enough research from the 'Forums Discussions", I was able to find the answer.
Field::inst( 'table.column' )
->options( Options::inst()
->table( 'table' )
->value( 'value' )
->label( 'label' )
->where( function ($q) {
$q->where( 'Column', "column value" );
} )
)
Thanks for the Forum Discussions!!!
Thanks for posting back. Good to hear you have it working now.
For reference, the list of methods available for the
Options
class is documented here.Allan
Thanks Allan!