CREATE TABLE `activity_statuses` ( `id` int(11) NOT NULL AUTO_INCREMENT, `statustypes_id` int(11) NOT NULL DEFAULT '0', `activities_id` int(11) NOT NULL DEFAULT '0', `created` datetime DEFAULT NULL, `created_by` int(11) DEFAULT NULL, `modified` datetime DEFAULT NULL, `modified_by` int(11) DEFAULT NULL, `_explicitType` varchar(45) NOT NULL DEFAULT 'ActivityStatus', PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=644 DEFAULT CHARSET=latin1;
This is the create table SQL for my activity_statuses table. If I do a direct insert via the ActivityStatus model, the dates get populated correct. Thanks for looking! Russ On Feb 17, 9:00 am, John Andersen <[email protected]> wrote: > What is the definition of your created and modified columns? Please do > a copy/paste :) > Enjoy, > John > > On 17 Feb., 16:40, rgreenphotodesign <[email protected]> > wrote: > > > > > > > > > I've set up (maybe the wrong approach) a HABTM relationship to handle > > status updates on a model record. For example: > > > Models: Activity, Statustype, ActivityStatus > > > In my Activity model, I created a belongsTo relationship with > > Statustype and the table contains a statustype_id (relationship is > > called CurrentStatustype). This represents the current status of the > > Activity. I also created a HABTM relationship (unique = false) with > > the ActivityStatus/Statustype model (named Statustype). The theory > > being, anytime an Activity is updated it gets the current status > > change in the Activity and then writes a 'history' to the > > ActivityStatus table. So far the automagic happens just the way I want > > with one exception. The HABTM relationship does not auto populate the > > created and modified date fields in the ActivityStatus table. I know > > for most HABTM relationships this wouldn't be an issue as you could > > simply get those dates from the Activity table. But as I'm trying to > > create a running history of status changes, the date fields become > > critical. > > > Is there a way to force these dates? Do I need to write a insertQuery > > in the relationship? Or do you think this is just a bad approach to > > the requirement? Thanks in advance. > > Russ -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php
