Editor with WHERE-clause Server-Side PHP table

Editor with WHERE-clause Server-Side PHP table

robbsandyrobbsandy Posts: 10Questions: 4Answers: 0

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

  • robbsandyrobbsandy Posts: 10Questions: 4Answers: 0
    edited January 2018

    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!!!

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

    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

  • robbsandyrobbsandy Posts: 10Questions: 4Answers: 0

    Thanks Allan!

This discussion has been closed.