We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

FR: Support for "IS NULL" and "IS NOT NULL"

Developer Preview

Manuel Payano's avatar
Manuel Payano
144 posts
9 years ago
Manuel Payano's avatar Manuel Payano

The current Model filters covers almost all of the uses cases.

Except it doesn’t work when you need to use: IS NULL or IS NOT NULL.

In EE2 you had to use an unescaped where() to get it done.

Same goes for BETWEEN.

Note: In my research i found filterGroup(), which is not documented. It’s super handy when you need a nested where clause.

ee('Model')->get('subs:Sub')->filter('status', 'IN', array('active', 'past_due', 'trialing'))
->filterGroup()
->filter('next_billing_at', '<', $date)
->orFilter('expires_at', '<', $date)
->endFilterGroup()
->batch(20, function($subs) {   

    // Loop over the current batch
    foreach ($subs as $num => $sub)
    {
        // Do your thing
    }

});
       
Seth Barber's avatar
Seth Barber
172 posts
9 years ago
Seth Barber's avatar Seth Barber

Hi Manuel,

Have you tried ->filter('column', '!=', 'NULL')?

       
Manuel Payano's avatar
Manuel Payano
144 posts
9 years ago
Manuel Payano's avatar Manuel Payano

Hi Seth,

That doesn’t work since it will produce: WHERE `column’ != ‘NULL’

To check for NULL you need to use: WHERE column IS NULL

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.