Ejemplo n.º 1
0
 /** Generate the SQL for pulling in all the data on a relationship **/
 public static function sqlRead($relationship)
 {
     $relname = TLO::transClassTable($relationship);
     $location_class = $relationship::relationMany();
     $relation_class = $relationship::relationOne();
     $query = new TLOQuery();
     $query->from(TLO::transClassTable($location_class));
     foreach (TLO::keyNames($location_class) as $key) {
         $query->select($key);
     }
     foreach (TLO::keyNames($relation_class) as $key) {
         $keyname = TLO::developedColName($relname, 'key', $key);
         $query->select($keyname);
         $query->where('%s IS NOT NULL', $keyname);
     }
     TLO::concreteClassLoop($relationship, __CLASS__, function ($class) use($relname, $query) {
         TLO::propertyLoop($class, __CLASS__, function ($p) use($relname, $query) {
             $query->select('%s AS %s', TLO::developedColName($relname, 'var', $p), $p);
         });
     });
     return $query;
 }
Ejemplo n.º 2
0
 public function testReadSpecifiedItems()
 {
     $query = new TLOQuery();
     $query->where('parent__key__id = ?');
     $r = TLO::getObjects($this->db, 'Test3', $query, array($this->guid2));
     $this->assertIsA($r, 'TLOObjectResult');
     $this->assertIsA($r->fetch(), 'Test3');
     $this->assertFalse($r->fetch());
 }