Now the query I was trying earlier is working. However, I need to also query a few other tables that are relations on my object, but the relations are not set as part as the Version object. I did override the setUp method of the version objects in order to benefit from the relations directly.
So far so good, in my action I can start a query like this: $q = Doctrine_Query::create() ->from('ObjectVersion ov') ->leftJoin('ov.Address a') This works just fine and I can create the query I want BUT BUT only as long as I create the query from the action... If I try to create that query from a "xxxTable" class for example, then the "Address" relation is not recognized anymore by Doctrine. Any ideas on this? On Wed, Dec 29, 2010 at 4:29 PM, Sebastien Armand [Pink] <khe...@gmail.com>wrote: > 1- When using the Doctrine plugin for symfony, and the versionable > behavior, the version classes don't seem to be generated like specified in > the Doctrine documentation. However the version classes for the forms are > generated. Is there a way to generate the model classes too? > > 2- Now more importantly, I want, through the version table, to get a > snapshot of what the main table was at a given time T. So I'm trying to > select only records that satisfy "updated_at" < T, but among those records I > might have multiple versions of the same record and I only want the one that > was the most up to date at time T. In SQL I can make a subquery on the same > table to get the maximum "updated_at" value before T or the maximum version > number with "updated_at" < T. > > The same request in DQL does not seem to work. If I try: > > $q = Doctrine_Core::getTable('ObjectVersion')->createQuery('fv1') > ->where('fv1.updated_at = (select max(fv2.updated_at) from > ObjectVersion fv2 where fv1.id = fv2.id and fv2.updated_at < > ?)','2010-12-29 06:40:59'); > > I get an exception "Couldn't find class fv2". > > However if I output the DQL from the query, what I get corresponds > perfectly to the SQL I could use directly in the DB... > > Any ideas are welcome! > > Thanks, > Khepin > -- If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com You received this message because you are subscribed to the Google Groups "symfony users" group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en