3448 Posts in 1062 Topics by 738 members
|Go to End|
12 May 2009 at 9:57am
I know you can do this with the SQLQuery object, but that makes it harder to get live/dev data appropriately.
I am trying to query data out using something like:
$posts = DataObject::get('Page', "`ClassName` IN ('EventEntry', 'NewsPage')");
But, the Date field is not named Date in one of these. So, I need to get "EventStartDate AS Date" worked in there somewhere.
My current solution is to query each of these out separately and use PHP to munge them together. Is there a built-in SilverStrip way to do this?
20 May 2009 at 8:26am
My solution for this was to change the database structure such that both objects had an EventStartDate. This worked because the site wasn't live yet and we were free to make changes. This would not work (at least not easily) in the case where the site was live and you had existing data.
So, I'm still looking for a reasonable solution to this problem. Surely I'm not the first person to have this problem.
20 May 2009 at 8:46am
You could have a getDate() (or just Date()) method that returns $this->EventStartDate or $this->dbObject('EventStartDate') depending on if you want the class associated with the field or just the field value.
|Go to Top|