Custom Parameter In Where Clause

Custom Parameter In Where Clause

nicontrolsnicontrols Posts: 32Questions: 16Answers: 1
edited October 2018 in Free community support

Hi, I'm struggling to find out how to pass a custom parameter to the where clause.

So far I have:

editor = new $.fn.dataTable.Editor( {
        ajax: {
            url: "../../controllers/test.php",
            type: "POST",
            data: {'custom': 123}
        },.....

And in test.php:

Editor::inst( $db, 'table', 'id' )
    ->fields(
        Field::inst( 'field1' ),
        Field::inst( 'field2' ),
        Field::inst( 'field3' )
        
    )
    ->where('field1',$_POST['custom'])
    ->process( $_POST )
    ->json();

However it returns a JSON error. Is there a way to pass a custom parameter?

Answers

  • nicontrolsnicontrols Posts: 32Questions: 16Answers: 1

    I was being an idiot.

    The ajax data needs to go in the DataTable function, not the Editor:

    $('#example').DataTable( {
    ajax: {
                url: "../../controllers/test.php",
                type: "POST",
                data: {'custom': 123}
            },.....
    
This discussion has been closed.