How to send a where statement to the server

How to send a where statement to the server

adminwgadminwg Posts: 2Questions: 0Answers: 0
edited January 2013 in Editor
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]

Replies

  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin
    Absolutely this can be done. The Editor class has a `where` method for exactly this: http://editor.datatables.net/docs/current/php/class-DataTables.Editor.html#_where

    Simply add something like:

    [code]
    ->where( 'auth_level', 2 )
    [/code]

    before the `process` call.

    Allan
  • adminwgadminwg Posts: 2Questions: 0Answers: 0
    edited February 2013
    Hey 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
  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin
    > But it would be phenomenal to have examples in the documentation.

    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
This discussion has been closed.