Hi guys,
I'm just trying to retrieve a child records where ThumbImage is not null or empty.
Is it possible to do something like this in SilverStripe?
$this->Children()->filter('ThumbImage not null')->sort('created', 'desc')->First();
Thank you
This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.
Please use forum.silverstripe.org for any new questions
(announcement).
The forum archive will stick around, but will be read only.
You can also use our Slack channel
or StackOverflow to ask for help.
Check out our community overview for more options to contribute.
Hi guys,
I'm just trying to retrieve a child records where ThumbImage is not null or empty.
Is it possible to do something like this in SilverStripe?
$this->Children()->filter('ThumbImage not null')->sort('created', 'desc')->First();
Thank you
$this->Children()->where('ThumbImage IS NOT NULL')->sort('created', 'desc')->first();
If the ThumbImage is a has_one relation, you have to use 'ThumbImageID' instead:
$this->Children()->where('ThumbImageID IS NOT NULL')->sort('created', 'desc')->first();
Thank you Devlin,
This is exactly what i was looking for :)