Be careful with the generateFiles option. This regenerates the files on *each* usage of the model class (see the change time of the generated file after a usage). And this creates serious troubles with APC, because APC always re-caches the file, and this leads to have cache fragmentation, and possibly segmentation faults. See http://www.doctrine-project.org/jira/browse/DC-974 If you experience this, consider setting apc.file_md5 to true.
Am 21.02.2011 08:02, schrieb Sebastien Armand [Pink]: > Found the reason behind this issue though I don't have any very good > solution for now, but in case someone else gets this kind of problem, > here it goes: > > First of all you need the 'generateFiles' option to be true when you > define your versionable models. Once this is done, you will have a new > 'ModelVersion' class file. The 'BaseModelVersion' class only defines > columns, not the relations. Copy pasting the relations defined in the > 'BaseModel' class into 'ModelVersion::setTableDefinition()' will do the > job and now your version class has its relations defined too. > > However if you ever create a query with the 'Model' class, since it has > the versionable behavior, it will define the 'ModelVersion' table > altogether. (Define here means in memory, for Doctrine to be able to > work with those table). This definition will be made through the > behavior and not through the files that we just created. Since Doctrine > makes use of some caching techniques, it won't redefine the > 'ModelVersion' when we try to use it. Therefore the relations won't be > set up. Whenever we want to use those version classes in a DQL query > with their related components, we need to redefine the table and erase > the version Doctrine could previously have. For this, just create an > object and use the setTableDefinition method: > > $object = new ModelVersion(); > $object->setTableDefinition(); > > From now on, the Version table is defined with the relations set. > > Looking at the code for the Versionable behavior I found a > 'generateRelations' option which is already set to 'true' by default. > However it is never used and doesn't link to anything. I guess there was > a plan to implement such possibilities but for whatever reason it didn't > happen. Since Doctrine's focus is now on Doctrine 2 and no longer on 1.2 > I don't see any change happening here so I'll keep using the workaround > I found. > > Hope this might be of some help to other people. > > > > > > > > On Thu, Jan 6, 2011 at 6:34 PM, Sebastien Armand [Pink] > <khe...@gmail.com <mailto:khe...@gmail.com>> wrote: > > 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 <mailto: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 > <http://fv1.id> = fv2.id <http://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 -- 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