RemoveDate Conflict

5 posts by 2 authors in: Forums > CMS Builder
Last Post: March 31, 2011   (RSS)

By wcd - March 29, 2011

I have a page that is loading different listings based on their category, which needs to be referenced through the query string (ex: "?event_type=Entertainment"). This works fine unless I have a value entered into the removeDate field, in which case the category/query string "filter" is no longer working. I'm guessing that I need to add something to or somehow modify the where clause? Here's what I have currently:

list($calendar_listingsRecords, $calendar_listingsMetaData) = getRecords(array(
'tableName' => 'calendar_listings',
'where' => "removeDate >= NOW() OR removeDate='0000-00-00 00:00:00'",
'ignoreRemoveDate' => true,
));

Re: [multimedia_nj] RemoveDate Conflict

By Jason - March 30, 2011

Hi,

Your query string looks correct. What is your page actually returning? Is it returning all records regardless of your event type?

Trying using this:
list($calendar_listingsRecords, $calendar_listingsMetaData) = getRecords(array(
'tableName' => 'calendar_listings',
'where' => "removeDate >= NOW() OR removeDate='0000-00-00 00:00:00'",
'ignoreRemoveDate' => true,
'debugSql' => true,
));


This will output the actual SQL query string being used. Let me know what you get.

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: [multimedia_nj] RemoveDate Conflict

By Jason - March 31, 2011

Hi,

The query you posted is for an event_type of "Promotion", not "Entertainment". I'm not sure if that changes things or not.

As for records with no removeDate not loading, my guess would be that the remove date field was added to the section after the record was created. This would mean that the removeDate field would have no value, not even "0000-00-00 00:00:00". There are a couple of ways to get around this, you could change your where clause like this:

list($calendar_listingsRecords, $calendar_listingsMetaData) = getRecords(array(
'tableName' => 'calendar_listings',
'where' => "(removeDate >= NOW() OR removeDate='0000-00-00 00:00:00' OR removeDate='')",
'ignoreRemoveDate' => true,

));


The other option is to leave removeDate out all together. I noticed that you're using the option "ignoreRemoveDate". If the actual value of remove date isn't important to your query, you can leave it out all together like this:

list($calendar_listingsRecords, $calendar_listingsMetaData) = getRecords(array(
'tableName' => 'calendar_listings',
'ignoreRemoveDate' => true,

));


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] RemoveDate Conflict

By wcd - March 31, 2011

Thanks Jason, the first solution worked. We have some listings that don't have remove dates, which is why we included the ignoreRemoveDate option. However, if there is a value in that field, then we do want the removeDate function to work.

Just for clarity's sake, in case anyone else is having a similar problem, the issue wasn't that records weren't loading, it was that all records with values in the removeDate fields were loading regardless of whether the event_type was "Promotion" or "Entertainment".