DataTables Editor SQl Query

DataTables Editor SQl Query

rcwebadminrcwebadmin Posts: 8Questions: 4Answers: 0

Hi everyone,

Using Datatables inline editor here, how can I show MSSQL results based off the category in php?

Editor::inst( $db, 'gen_ed_assessment.responses_data_record')
    ->fields(
        Field::inst( 'instructor1_full_name' )->validator( 'Validate::notEmpty' ),
        Field::inst( 'category' )->validator( 'Validate::notEmpty' ),
        Field::inst( 'Metric_text' ),

Instead of using the gen_ed_assessment.responses_data_record, can I do a simply SQL query like Select * from gen_ed_assessment.responses_data_record where category like 'TEST'. I'm just not sure how to go about doing that so the results will only show "Test" in the example.

Thanks

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,522Questions: 1Answers: 10,473 Site admin

    Unfortunately no - you need to specify each field individually. While Editor interfaces with an SQL database, it also needs to process the data itself, so it need to know about each field.

    Allan

  • rcwebadminrcwebadmin Posts: 8Questions: 4Answers: 0

    Thanks Allan, I have found that I can use the search field to populate based off a column, wondering if I can use this to populate based off the username login? (laravel 4.2 framework)

  • allanallan Posts: 63,522Questions: 1Answers: 10,473 Site admin

    Just to confirm - you want to use a conditional expression (i.e. a where)? If so, the documentation on how to do that is available in the Editor manual.

    Regards,
    Allan

  • rcwebadminrcwebadmin Posts: 8Questions: 4Answers: 0

    Hi Allan,

    I am wanting to use the current username (in php) and pass that variable to the DataTable so when the user logs into the applicaiton and Sees the DataTable, they will only see the rows that relate to them, based off a column with their username. So for example if I log in and my username is Smith for example, Then I would only see all the records pertaining to Smith. When someone else logs in under a different name like Doe, they see only the records that go with Doe.

    My thinking was by populating the search box this would fix it. Do you know of another way with a code example to accomplish this?

  • allanallan Posts: 63,522Questions: 1Answers: 10,473 Site admin
    Answer ✓

    The where conditions that I linked to sounds perfect. Does that not suit your needs?

    Allan

  • rcwebadminrcwebadmin Posts: 8Questions: 4Answers: 0

    I believe it will, looking at it here and I'm going to try and apply it. Will mark it as answered if I can get it to work lol

This discussion has been closed.