question to sql-server view alternative to "where"

question to sql-server view alternative to "where"

MadMax76MadMax76 Posts: 149Questions: 33Answers: 1
edited January 2021 in Free community support

I need the case of getting data from a view, but putting data back into a table as described in https://editor.datatables.net/examples/advanced/sqlView.html

In the description it sayss that using views is an alternativ to having a "where"-clause, that would only be true if I can also filter the view by sending a whre-clause there - or did i understand that wrong?

My second question (sorry i am quite a beginner and digging into this):
Where do i need to put this

$editor
           ->where( 'INP_ID', __freigeber_INP_ID__ )
           ->where( 'Stapelname', __freigeber_Stapelname__ );

to get the filter running? Does this go into <table ID="example" ... > or into the editor-part or datatable?

Thanks
Max

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,214Questions: 1Answers: 10,415 Site admin
    Answer ✓

    Hi Max,

    did i understand that wrong?

    No you didn’t - you are spot on. The intention with my phrasing there was that you might have a condition inside the VIEW. But equally you could also apply a condition to the VIEW using a ->where() call as normal.

    The code you have there should go into the PHP code you are using for the database interaction. For example:

    Editor::inst( $db, '...' )
        ->fields(
            ...
        )
        ->where( ... )
        ->process( $_POST )
        ->json();
    

    Allan

This discussion has been closed.