Can removeDate be optional?
5 posts by 2 authors in: Forums > CMS Builder
Last Post: November 30, 2010 (RSS)
By zip222 - November 29, 2010 - edited: November 30, 2010
Re: [zip222] Can removeDate be optional?
By Jason - November 30, 2010
The removeDate is optional, but by default it will be factored into your query. If a date field is empty, it is stored as a value of 0000-00-00 00:00:00.
If you want to have removeDate as a field but only want it to be factored if removeDate actually has a value, you can structure your query like this:
list($newsRecord, $newsMetaData) = getRecords(array(
'tableName' => 'news',
'where' => "removeDate >= NOW() OR removeDate='0000-00-00 00:00:00'",
'ignoreRemoveDate' => true,
));
ignoreRemoveDate will take away the automatic where clause that removeDate creates. We then create our own where clause that looks for removeDate to be after the current date, or to have no value.
Hope this helps
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
Re: [Jason] Can removeDate be optional?
By zip222 - November 30, 2010
'where' => 'archive=0',
'where' => "removeDate >= NOW() OR removeDate='0000-00-00 00:00:00'",
Re: [zip222] Can removeDate be optional?
By Jason - November 30, 2010
Try this:
'where' => "(removeDate >= NOW() OR removeDate='0000-00-00 00:00:00') AND archive=0",
In this example, it will only return records where the archive checkbox hasn't been checked.
Hope this helps
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
Re: [Jason] Can removeDate be optional?
By zip222 - November 30, 2010