I see an unexpected caching effect in Doctrine (1.2.4).
I have a couple of related tables defined by the following YAML (a few extra fields that are not used in the example are deleted). Just a simple β1-Manyβ relationship from students to schools.
School: tableName: tblschool columns: sch_id: name: sch_id as id primary: true autoincrement: true type: integer(4) sch_name: name: sch_name as name type: string(50) Student: tableName: tblstudent columns: stu_id: name: stu_id as id primary: true autoincrement: true type: integer(4) stu_sch_id: name: stu_sch_id as school_id type: integer(4) relations: School: local: school_id foreign: id foreignAlias: Students
I can create a simple Doctrine query (1.2.4) to get the student back using
$result1 = Doctrine_Query::create() ->from('Student s') ->where('s.id = 1') ->execute();
and then cross out the appropriate school name with
foreach ($result1 as $result) { $ans[] = $result->School["name"]; }
Now I am changing school_id (which calls the connection), following this with:
foreach ($result1 as $result) { $result["school_id"] = 1 - $result["school_id"]; $result->save(); }
(I created a database so that it gives another valid school identifier).
If I were now, immediately, try to access the relationship, I will get the old name of the school. I understand this - this is because I did not call refreshRelated (). What I find unexpected is that if I immediately make another request duplicating the first
$result2 = Doctrine_Query::create() ->from('Student s') ->where('s.id = 1') ->execute();
and get his result
foreach ($result2 as $result) { $ans[] = $result->School["name"]; }
when I look at the contents of my array, I find that in both cases I have the same school name. In other words, although I made a second request and look at the result of the request, the connection is not updated.
The data in the database is accurate and consistent; those. there are relevant students and schools. For example. performing the above sequence a second time β when executing another program β uses a different school name (although it is duplicated again).
Where does this caching come from?