How to send a where statement to the server
How to send a where statement to the server
Hello,
I would like to be able to query the table. For example, I would like to call this datase but display only members who had an auth_level of 2.
Whit
[code]
Editor::inst( $db, 'icdm_members' )
->fields(
Field::inst( 'usr' )
->validator( 'Validate::required' ),
Field::inst( 'email' )
->validator( 'Validate::email' ),
Field::inst( 'regIP' )
->validator( 'Validate::ip' ),
Field::inst( 'dt' )
->validator( 'Validate::dateFormat_required', array(
"format" => Format::DATE_ISO_8601,
"message" => "Please enter a date in the format yyyy-mm-dd"
) ),
Field::inst( 'auth_level' )
->validator( 'Validate::required' )
)
->process( $_POST )
->json();
[/code]
I would like to be able to query the table. For example, I would like to call this datase but display only members who had an auth_level of 2.
Whit
[code]
Editor::inst( $db, 'icdm_members' )
->fields(
Field::inst( 'usr' )
->validator( 'Validate::required' ),
Field::inst( 'email' )
->validator( 'Validate::email' ),
Field::inst( 'regIP' )
->validator( 'Validate::ip' ),
Field::inst( 'dt' )
->validator( 'Validate::dateFormat_required', array(
"format" => Format::DATE_ISO_8601,
"message" => "Please enter a date in the format yyyy-mm-dd"
) ),
Field::inst( 'auth_level' )
->validator( 'Validate::required' )
)
->process( $_POST )
->json();
[/code]
This discussion has been closed.
Replies
Simply add something like:
[code]
->where( 'auth_level', 2 )
[/code]
before the `process` call.
Allan
I am going to purchase a license today thanks to your brilliance on this. THe documentation is great and the examples are great. But it would be phenomenal to have examples in the documentation. I looked at that page but did not figure out that it applied to editor or where to put it.
One more thing where do you recommend for passing where statements to editor. In other words certain users will have rights to see certain data. Using session variables and php would be my best guess.
Thanks again
Agreed - I think the PHP documentation needs a few examples in its API methods. Thanks very much for the feedback on this - and your purchase of Editor!
> Using session variables and php would be my best guess.
Agreed again :-). You could send it to the server from Javascript with fnServerParams in DataTables, but I'd suggest that would be a security issue since the user could easily change the values sent. Keeping that information on the server is the right approach to my mind!
Regards,
Allan