Editor where not filtering

Editor where not filtering

borconiborconi Posts: 56Questions: 19Answers: 1

Hi. I'm trying to familiarize myself with Editor (quite like it till now!) but I'm having difficulties understanding what I'm doing wrong if anything.

This is my server side PHP:

<?php

// DataTables PHP library
include("./csat.php");
include( "./php/DataTables.php" );


// Alias Editor classes so they are easy to use
use
    DataTables\Editor,
    DataTables\Editor\Field,
    DataTables\Editor\Format,
    DataTables\Editor\Mjoin,
    DataTables\Editor\Upload,
    DataTables\Editor\Validate;

// Build our Editor instance and process the data coming from _POST
$editor=Editor::inst( $db, 'job_descriptions' )
    ->fields(
        
        Field::inst( 'Description' )->validator( 'Validate::notEmpty' )
        
    );
    
    $editor->process( $_POST );
    $editor->where('owner',2,'=');
    $editor->json();

It all works well, except that no matter what I change in the $editor->where('owner',2,'='); it will still return every row from the table rather than those where the owner value is 2.

Am I doing something wrong?

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,815Questions: 1Answers: 10,517 Site admin
    Answer ✓

    Put the where() line before the process() one.

    The process() method basically processed the setup - so everything, with the exception of the json() call (which gets the result of the processing) should come before process().

    Regards,
    Allan

  • borconiborconi Posts: 56Questions: 19Answers: 1

    Thank you @allan!

    Now I feel like a total idiot.... :smile: made sense the minute I read your comment.

This discussion has been closed.