[limb-svn] r6700 - in 3.x/trunk/limb/active_record: src tests/cases

svn at limb-project.com svn at limb-project.com
Fri Jan 18 12:27:03 MSK 2008


Author: serega
Date: 2008-01-18 12:27:02 +0300 (Fri, 18 Jan 2008)
New Revision: 6700
URL: http://fisheye.limb-project.com/changelog/limb/?cs=6700

Modified:
   3.x/trunk/limb/active_record/src/lmbARQuery.class.php
   3.x/trunk/limb/active_record/src/lmbARRecordSetJoinDecorator.class.php
   3.x/trunk/limb/active_record/src/lmbARRelationCollection.class.php
   3.x/trunk/limb/active_record/tests/cases/lmbARManyToManyRelationsTest.class.php
   3.x/trunk/limb/active_record/tests/cases/lmbAROneToManyRelationsTest.class.php
   3.x/trunk/limb/active_record/tests/cases/lmbARQueryTest.class.php
   3.x/trunk/limb/active_record/tests/cases/lmbActiveRecordTest.class.php
Log:
-- lmbARQuery :: with() -> :: join()

Modified: 3.x/trunk/limb/active_record/src/lmbARQuery.class.php
===================================================================
--- 3.x/trunk/limb/active_record/src/lmbARQuery.class.php	2008-01-18 09:03:08 UTC (rev 6699)
+++ 3.x/trunk/limb/active_record/src/lmbARQuery.class.php	2008-01-18 09:27:02 UTC (rev 6700)
@@ -14,7 +14,7 @@
 {
   protected $_base_class_name;
   protected $_base_object;
-  protected $_with = array();
+  protected $_join = array();
   protected $_attach = array();
   
   function __construct($base_class_name, $conn, $sql = '')
@@ -34,9 +34,9 @@
     }
   }
   
-  function with($relation_name, $params = array())
+  function join($relation_name, $params = array())
   {
-    $this->_with[$relation_name] = $params;
+    $this->_join[$relation_name] = $params;
 
     return $this;
   }
@@ -56,7 +56,7 @@
   
   function fetch($decorate = true)
   {
-    $this->_applyJoins($this->_base_object, $this->_with);
+    $this->_applyJoins($this->_base_object, $this->_join);
     
     $rs = parent :: fetch();
 
@@ -112,15 +112,15 @@
         break;
       }
       
-      if(isset($params['with']))
-        $this->_applyJoins($object, $params['with'], $prefix . $relation_name);
+      if(isset($params['join']))
+        $this->_applyJoins($object, $params['join'], $prefix . $relation_name);
     }
   }
 
   protected function _decorateWithJoinDecorator($rs)
   {
-    if(count($this->_with))
-      return new lmbARRecordSetJoinDecorator($rs, $this->_base_object, $this->_conn, $this->_with);
+    if(count($this->_join))
+      return new lmbARRecordSetJoinDecorator($rs, $this->_base_object, $this->_conn, $this->_join);
     else
       return $rs;
   }
@@ -162,16 +162,16 @@
     $sort_params = (isset($params['sort']) && $params['sort']) ? $params['sort'] : $object->getDefaultSortParams();
     $query->order($sort_params);
 
-    $with = (isset($params['with']) && $params['with']) ? $params['with'] : array();
-    if(!is_array($with))
-      $with = explode(',', $with);
+    $join = (isset($params['join']) && $params['join']) ? $params['join'] : array();
+    if(!is_array($join))
+      $join = explode(',', $join);
     
-    foreach($with as $relation_name=> $params_or_relation_name)
+    foreach($join as $relation_name=> $params_or_relation_name)
     {
       if(is_numeric($relation_name))
-        $query->with(trim($params_or_relation_name));
+        $query->join(trim($params_or_relation_name));
       else
-        $query->with(trim($relation_name), $params_or_relation_name);
+        $query->join(trim($relation_name), $params_or_relation_name);
     }
 
     $attach = (isset($params['attach']) && $params['attach']) ? $params['attach'] : array();

Modified: 3.x/trunk/limb/active_record/src/lmbARRecordSetJoinDecorator.class.php
===================================================================
--- 3.x/trunk/limb/active_record/src/lmbARRecordSetJoinDecorator.class.php	2008-01-18 09:03:08 UTC (rev 6699)
+++ 3.x/trunk/limb/active_record/src/lmbARRecordSetJoinDecorator.class.php	2008-01-18 09:27:02 UTC (rev 6700)
@@ -41,8 +41,8 @@
     {
       $relation_info = $this->base_object->getRelationInfo($relation_name);
       $object = new $relation_info['class'];
-      if(isset($params['with']))
-        $this->iterator = new lmbARRecordSetJoinDecorator($this->iterator, $object, $this->conn, $params['with'], $this->prefix . $relation_name . '__');
+      if(isset($params['join']))
+        $this->iterator = new lmbARRecordSetJoinDecorator($this->iterator, $object, $this->conn, $params['join'], $this->prefix . $relation_name . '__');
       if(isset($params['attach']))
         $this->iterator = new lmbARRecordSetAttachDecorator($this->iterator, $object, $this->conn, $params['attach'], $relation_name . '__');
     }

Modified: 3.x/trunk/limb/active_record/src/lmbARRelationCollection.class.php
===================================================================
--- 3.x/trunk/limb/active_record/src/lmbARRelationCollection.class.php	2008-01-18 09:03:08 UTC (rev 6699)
+++ 3.x/trunk/limb/active_record/src/lmbARRelationCollection.class.php	2008-01-18 09:27:02 UTC (rev 6700)
@@ -91,7 +91,7 @@
     if(!isset($magic_params['sort']) && isset($this->default_params['sort']))
       $magic_params['sort'] = $this->default_params['sort'];
     
-    $magic_params['with'] = $this->join_relations;
+    $magic_params['join'] = $this->join_relations;
     $magic_params['attach'] = $this->attach_relations;
     
     $query = $this->_createARQuery($magic_params);
@@ -109,7 +109,7 @@
       return $rs->current();
   }
   
-  function with($relation_name, $params = array())
+  function join($relation_name, $params = array())
   {
     $this->join_relations[$relation_name] = $params;
     return $this;

Modified: 3.x/trunk/limb/active_record/tests/cases/lmbARManyToManyRelationsTest.class.php
===================================================================
--- 3.x/trunk/limb/active_record/tests/cases/lmbARManyToManyRelationsTest.class.php	2008-01-18 09:03:08 UTC (rev 6699)
+++ 3.x/trunk/limb/active_record/tests/cases/lmbARManyToManyRelationsTest.class.php	2008-01-18 09:27:02 UTC (rev 6700)
@@ -103,7 +103,7 @@
     $group->setUsers(array($user1, $user2));    
 
     $group2 = lmbActiveRecord :: findById('GroupForTest', $group->getId());
-    $arr = $group2->getUsers()->with('linked_object')->getArray();
+    $arr = $group2->getUsers()->join('linked_object')->getArray();
 
     //make sure we really eager fetching
     $this->db->delete('test_one_table_object');

Modified: 3.x/trunk/limb/active_record/tests/cases/lmbAROneToManyRelationsTest.class.php
===================================================================
--- 3.x/trunk/limb/active_record/tests/cases/lmbAROneToManyRelationsTest.class.php	2008-01-18 09:03:08 UTC (rev 6699)
+++ 3.x/trunk/limb/active_record/tests/cases/lmbAROneToManyRelationsTest.class.php	2008-01-18 09:27:02 UTC (rev 6700)
@@ -378,7 +378,7 @@
     $this->assertFalse($course->trySave($error_list));
   }
   
-  function testFetchWithRelatedObjects_UsingWithMethod()
+  function testFetchWithRelatedObjects_UsingJoinMethod()
   {
     $course = $this->creator->createCourse();
     
@@ -389,7 +389,7 @@
     $lecture2 = $this->creator->createLecture($course, $alt_course2);
     $lecture3 = $this->creator->createLecture($course, $alt_course1);
     
-    $lectures = $course->getLectures()->with('course')->with('alt_course');
+    $lectures = $course->getLectures()->join('course')->join('alt_course');
     $arr = $lectures->getArray();
     
     //make sure we really eager fetching

Modified: 3.x/trunk/limb/active_record/tests/cases/lmbARQueryTest.class.php
===================================================================
--- 3.x/trunk/limb/active_record/tests/cases/lmbARQueryTest.class.php	2008-01-18 09:03:08 UTC (rev 6699)
+++ 3.x/trunk/limb/active_record/tests/cases/lmbARQueryTest.class.php	2008-01-18 09:27:02 UTC (rev 6700)
@@ -30,7 +30,7 @@
     $this->assertEqual($arr[1]->getAnnotation(), $object2->getAnnotation());
   }
   
-  function testFetch_With_RelatedHasOneObject()
+  function testFetch_Join_RelatedHasOneObject()
   {
     $person1 = $this->creator->createPerson();
     $person2 = $this->creator->createPerson();
@@ -38,7 +38,7 @@
     $this->conn->reset();
     
     $query = new lmbARQuery('PersonForTest', $this->conn);
-    $query->with('social_security');
+    $query->join('social_security');
     $iterator = $query->fetch();
     $arr = $iterator->getArray();
     
@@ -62,7 +62,7 @@
     $this->assertEqual($this->conn->count(), 0);
   }
 
-  function testFetch_With_RelatedBelongsToObject()
+  function testFetch_Join_RelatedBelongsToObject()
   {
     $person1 = $this->creator->createPerson();
     $ss1 = $person1->getSocialSecurity();
@@ -72,7 +72,7 @@
     $this->conn->reset();
     
     $query = new lmbARQuery('SocialSecurityForTest', $this->conn);
-    $query->with('person');
+    $query->join('person');
     $iterator = $query->fetch();
     $arr = $iterator->getArray();
 
@@ -96,7 +96,7 @@
     $this->assertEqual($this->conn->count(), 0);
   }
 
-  function testFetch_With_RelatedManyBelongsToObject()
+  function testFetch_Join_RelatedManyBelongsToObject()
   {
     $course1 = $this->creator->createCourse();
     $course2 = $this->creator->createCourse();
@@ -107,7 +107,7 @@
     $this->conn->reset();
     
     $query = new lmbARQuery('LectureForTest', $this->conn);
-    $query->with('course');
+    $query->join('course');
     $iterator = $query->fetch();
     $arr = $iterator->getArray();
     
@@ -144,7 +144,7 @@
     $this->conn->reset();
     
     $query = new lmbARQuery('PersonForTest', $this->conn);
-    // note attach() has the same effect as with() but workds is a different way - it produces another sql request 
+    // note attach() has the same effect as join() but workds is a different way - it produces another sql request 
     $iterator = $query->attach('social_security')->fetch();
     $arr = $iterator->getArray();
     
@@ -180,7 +180,7 @@
     $this->conn->reset();
     
     $query = new lmbARQuery('SocialSecurityForTest', $this->conn);
-    // note attach() has the same effect as with() but workds is a different way - it produces another sql request 
+    // note attach() has the same effect as join() but workds is a different way - it produces another sql request 
     $arr = $query->attach('person')->fetch()->getArray();
 
     $this->assertEqual($this->conn->count(), 2);
@@ -340,7 +340,7 @@
     $this->assertEqual($this->conn->count(), 0);
   }
 
-  function testFetch_NestedWithProperty_In_Attach_ForHasMany()
+  function testFetch_NestedJoinProperty_In_Attach_ForHasMany()
   {
     $course1 = $this->creator->createCourse();
     $course2 = $this->creator->createCourse();
@@ -357,7 +357,7 @@
     
     $query = new lmbARQuery('CourseForTest', $this->conn);
     $query->where(lmbSQLCriteria :: in('id', array($course1->getId(), $course2->getId())));
-    $arr = $query->attach('lectures', array('with' => 'alt_course'))->fetch()->getArray();
+    $arr = $query->attach('lectures', array('join' => 'alt_course'))->fetch()->getArray();
     
     $this->assertEqual($this->conn->count(), 2);
     
@@ -389,7 +389,7 @@
     $this->assertEqual($this->conn->count(), 0);
   }  
   
-  function testFetch_NestedAttachProperty_In_With()
+  function testFetch_NestedAttachProperty_In_Join()
   {
     $course1 = $this->creator->createCourse();
     $course2 = $this->creator->createCourse();
@@ -411,7 +411,7 @@
 
     $query = new lmbARQuery('LectureForTest', $this->conn);
     $query->where(lmbSQLCriteria :: equal('course_id', $course1->getId()));
-    $iterator = $query->with('alt_course', array('attach' => 'lectures'))->fetch();
+    $iterator = $query->join('alt_course', array('attach' => 'lectures'))->fetch();
     $arr = $iterator->getArray();
     
     $this->assertEqual($this->conn->count(), 2);
@@ -445,7 +445,7 @@
     $this->assertEqual($this->conn->count(), 0);
   }  
 
-  function testFetchNested_AttachProperty_In_WithProperty_In_Attach()
+  function testFetchNested_AttachProperty_In_JoinProperty_In_Attach()
   {
     $course1 = $this->creator->createCourse();
     $course2 = $this->creator->createCourse();
@@ -467,7 +467,7 @@
     
     $query = new lmbARQuery('CourseForTest', $this->conn);
     $query->where(lmbSQLCriteria :: in('id', array($course1->getId(), $course2->getId())));
-    $arr = $query->attach('lectures', array('with' => array('alt_course' => array('attach' => 'lectures'))))->fetch()->getArray();
+    $arr = $query->attach('lectures', array('join' => array('alt_course' => array('attach' => 'lectures'))))->fetch()->getArray();
 
     $this->assertEqual($this->conn->count(), 3);
     
@@ -513,7 +513,7 @@
     $this->assertEqual($this->conn->count(), 0);
   }  
   
-  function testFetch_NestedWithProperty_In_With()
+  function testFetch_NestedJoinProperty_In_Join()
   {
     $program1 = $this->creator->createProgram();
     $program2 = $this->creator->createProgram();
@@ -525,7 +525,7 @@
     $this->conn->reset();
     
     $query = new lmbARQuery('LectureForTest', $this->conn);
-    $iterator = $query->with('course', array('with' => 'program'))->fetch();
+    $iterator = $query->join('course', array('join' => 'program'))->fetch();
     $arr = $iterator->getArray();
     
     $this->assertEqual($this->conn->count(), 1);

Modified: 3.x/trunk/limb/active_record/tests/cases/lmbActiveRecordTest.class.php
===================================================================
--- 3.x/trunk/limb/active_record/tests/cases/lmbActiveRecordTest.class.php	2008-01-18 09:03:08 UTC (rev 6699)
+++ 3.x/trunk/limb/active_record/tests/cases/lmbActiveRecordTest.class.php	2008-01-18 09:27:02 UTC (rev 6700)
@@ -635,7 +635,7 @@
     $lecture2 = $this->creator->createLecture($course2, $alt_course2);
     $lecture3 = $this->creator->createLecture($course1, $alt_course2);
     
-    $rs = lmbActiveRecord :: find('LectureForTest', array('with' => 'course, alt_course'));
+    $rs = lmbActiveRecord :: find('LectureForTest', array('join' => 'course, alt_course'));
     $arr = $rs->getArray();
 
     //make sure we really eager fetching



More information about the limb-svn mailing list