Unable to see result on my WHERE clause on editor
Unable to see result on my WHERE clause on editor
Hi,
as mentioned here http://editor.datatables.net/docs/current/php/source-class-DataTables.Editor.html#356 i'm trying to find a way to make things work.
So lets immagine i have some columns like name, company, owner.
Now i need to modify my WHERE in order to view all records with owner=john.
So if i understand well i should simply modify the function as foolow:
public function where ( $key=owner, $value=john, $op='=' )
Am i correct?
Cause these way doesn't produce any effect...
Thank you
This question has an accepted answers - jump to answer
Answers
Ohh...find it
just put:
// Build our Editor instance and process the data coming from _POST
Editor::inst( $db, 'addressbook' )
->fields(
Field::inst( 'name' ),
Field::inst( 'company' ),
Field::inst( 'email' ),
Field::inst( 'owner' ),
Field::inst( 'public' )
)
->where( $key = "owner", $value = "john", $op = "=" )
->process( $_POST )
->json();
My last question would be:
How to extend this with an additional WHERE clause with OR / AND operator?
So for example how retrieve records when owner=john OR / AND public=yes ?
Thank you
Hi,
Good to hear you got your initial question resolved.
Currently the Editor
where
option only operates on an AND basis. There is no option to use an OR option. It is something I'm going to look at adding in future, particularly now that the join operation have been improved, but for now you would need to query the database directly with your query and output the data as JSON.Allan
ok understand.
And what about inserting a second WHERE clause with and operator?
How the code shoul be?
Thank You
Just call the
where
method again:Allan