NULL values with WHERE method

NULL values with WHERE method

WakaruWakaru Posts: 13Questions: 5Answers: 0
edited October 2014 in DataTables 1.10

Hi,

I'm trying to use where -method to match NULL -values from the column named 'COMMENT'. What is the proper syntax for this operation (or is there one)?

I have tried several ways of doing this but can't get it to work. Here's one example:

$editor->where( $key = 'COMMENT', $value = '', $op = 'IS NULL' );

Thanks!

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,744Questions: 1Answers: 10,111 Site admin

    Hi,

    I don't think there is a proper way of doing this with the libraries at the moment I'm afraid. Let me look into it and I'll get back to you, but I suspect it will need the updates I'm planning for 1.4...

    Allan

  • allanallan Posts: 61,744Questions: 1Answers: 10,111 Site admin

    Hi,

    I've just implemented this for the 1.4 release but it does require an update to the PHP libraries - if you'd like me to send over a copy of the current dev files, just let me know and I'll e0mail them through to the address for your account.

    With the new libraries what you can do is use the second parameter (the value) as null to match on null:

    $editor->where( 'COMMENT', null );
    

    Which is identical to:

    $editor->where( 'COMMENT', null, '=' );
    

    (i.e. COMMENT = null - the database abstraction will convert that to be IS NULL).

    Likewise for IS NOT NULL you would do:

    $editor->where( 'COMMENT', null, '!=' );
    

    Allan

  • WakaruWakaru Posts: 13Questions: 5Answers: 0

    Thanks, it would be great to have those files.

  • allanallan Posts: 61,744Questions: 1Answers: 10,111 Site admin
    Answer ✓

    E-mail sent :-)

    Allan

This discussion has been closed.