Пример #1
0
 public function testPropertyLoop()
 {
     $properties = array();
     TLO::propertyLoop('Test1', 'TLO', function ($p) use(&$properties) {
         $properties[] = $p;
     });
     $this->assertEqual($properties, array('foo'));
     $properties = array();
     TLO::propertyLoop('Test2', 'TLO', function ($p) use(&$properties) {
         $properties[] = $p;
     });
     $this->assertEqual($properties, array());
     $properties = array();
     TLO::propertyLoop('Test3', 'TLO', function ($p) use(&$properties) {
         $properties[] = $p;
     });
     $this->assertEqual($properties, array('baz', 'bar'));
 }
Пример #2
0
 /** Write the relationship to the DB **/
 public function write(PDO $db = NULL)
 {
     if (is_null($db)) {
         $db = $this->_db;
     }
     $relationship = get_class($this);
     $relname = TLO::transClassTable($relationship);
     $location_class = $relationship::relationMany();
     $relation_class = $relationship::relationOne();
     $query = self::sqlWrite($relationship);
     $params = array();
     $obj = $this;
     TLO::concreteClassLoop($relationship, __CLASS__, function ($class) use($relname, &$params, $obj) {
         TLO::propertyLoop($class, __CLASS__, function ($p) use($relname, &$params, $obj) {
             $params[] = $obj->{$p};
         });
     });
     foreach ($this->getKeys() as $key => $val) {
         $params[] = $val;
     }
     $s = TLO::prepare($db, $query);
     TLO::execute($s, $params);
 }