hi,
I'm running into a few issues with 2 HABTM associations. I'm working
on a events listing app (bit like upcoming.org but more specific) and
I have a tagging system in place. I have the following tables:
events
tags
events_tags
I want to be able to list events by date, and also only show events
that come after the current date, basiucally doing:
Event.event_start > now()
but no matter what I try I can't get Cake to do it.
Originally I tried:
var $hasAndBelongsToMany = array(
'Event' =>
array( 'className' => 'Event',
'joinTable' =>
'events_tags',
'foreignKey' => 'tag_id',
'associationForeignKey' => 'event_id',
'conditions' => 'Event.event_start >
now()',
'order' => '',
'uniq' => true,
'finderSql' => '',
'deleteSql' => '',
'insertSql' => '',
)
But I get an SQL error because Cake isn't querying the Events table,
so Event.event_start isn't available. I then tried manually entering
the sql using finderQuery like so:
'SELECT Tag.id, Tag.name, Tag.handle, Tag.description, Tag.tag_count,
Tag.created, Tag.modified FROM tags,events AS Tag,Event JOIN
events_tags ON events_tags.event_id = {$__cakeID__$} AND
events_tags.tag_id = Tag.id WHERE events.event_start > now()'
I think it's basically a lack of SQL knowledge that's letting me down,
but I'm not sure how to go about it, what I'm trying to write is:
'select all events with the tag_id of 'nn' that have an event_start
date after the current time' (I think!)
Any help from anyone hugely appreciated!
thanks,
jon
--
jon bennett
t: +44 (0) 1225 341 039 w: http://www.jben.net/
iChat (AIM): jbendotnet Skype: jon-bennett
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---