Where clause in editor post action

Where clause in editor post action

mRendermRender Posts: 151Questions: 26Answers: 13

I was wondering why I was getting invalid JSON from this because of my where clause.

if ( !isset($_POST['action']) ) {
    // Get a list of sites for the `select` list
    $data['tbl_Login'] = $db
        ->selectDistinct( 'tbl_Login', 'UID as value, email as label' )
        ->where('UID', 1)
        ->fetchAll();
}

Shouldn't I be able to have a where clause and only select the users with UID = 1?

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,723Questions: 1Answers: 10,108 Site admin
    Answer ✓

    The selectDistinct method returns a Result - not a Query instance, so it doesn't have a where method.

    You can pass in a third parameter to selectDistinct to act as a select (docs).

    if ( !isset($_POST['action']) ) {
        // Get a list of sites for the <code>select</code> list
        $data['tbl_Login'] = $db
            ->selectDistinct( 'tbl_Login', 'UID as value, email as label', array( 'UID'=>1) )
            ->fetchAll();
    }
    

    Allan

This discussion has been closed.