where clause in mjoin?
where clause in mjoin?
mf
Posts: 41Questions: 11Answers: 0
in DataTables
Hello, does anyone know if it is possible to use a where clause in mjoin? like this:
->join(
Mjoin::inst( 'dealers' )
->link( 'dealercontacts.dealercontacts_id', 'dealers_dealercontacts.dealercontacts_id' )
->link( 'dealers.dealernr', 'dealers_dealercontacts.dealernr' )
->order( 'dealernr asc' )
->fields(
Field::inst( 'dealernr' )
->validator( 'Validate::required' )
->options( Options::inst()
->table( 'dealers' )
->value( 'dealernr' )
->label( array('dealernr', 'naam', 'bezoek_plaats') )
->where( function ( $r ) {
$r->or_where( 'contract', 'M' );
$r->or_where( 'contract', 'S' );
$r->or_where( 'contract', 'SAT' );
$r->or_where( 'contract', 'REP' );
} )
),
Field::inst( 'naam' )
)
)
I can't find it in the manual so I guess it is not possible. As alternative I could create a view of the dealer table where I leave out anything but M, S, SAT and REP. I don't need to write anything to that table.
Thanks!!
This question has accepted answers - jump to:
This discussion has been closed.
Answers
Great question. I used a view to handle a situation like this. However, from the documentation it seems like it should work.(https://editor.datatables.net/docs/1.7.2/php/class-DataTables.Database.Query.html)
Did you try it with just one of the options?
ex:
If that doesn't work then you should probably use a view.
Yes the
Mjoin
class has awhere
method that you can use to apply conditions to what is joined.Allan
thanks, it works!!
Hi,
Good day.
Do you have an example of this in NodeJS? Thanks.
Regards.
wold be the equivalent in Node. More on using conditions in Node available here.
Allan
Thanks Allan. Works.