Example #1
0
 /**
  * Get a record in the given table.
  * This class is usually instantiated by Driver::getRecords(), which
  * sets column values as properties.
  * @param Table $table
  * @param bool $exists Is this a real record, or a new one that we will probably insert later?
  * @param array $data optional array of properties => values
  */
 public function __construct(Table $table, $exists = true, $data = null)
 {
     $this->_meta['table'] = $table;
     $this->_meta['exists'] = $exists;
     $this->_meta['existed'] = $exists;
     $this->_meta['driver'] = $table->getDriver();
     if (isset($data)) {
         foreach ($data as $key => $value) {
             $this->{$key} = $value;
         }
     }
     foreach ($table->getForeignKeys() as $localColumn => $foreignKey) {
         if (property_exists($this, $localColumn)) {
             $this->_meta['foreignRecords'][$localColumn] = $this->{$localColumn};
             // unset the property, so that the magic __getter will be invoked
             unset($this->{$localColumn});
         } else {
             $this->_meta['foreignRecords'][$localColumn] = null;
         }
     }
 }
Example #2
0
 /**
  * Make a record set for the given table
  * @param Table $table
  */
 protected function __construct(Table $table)
 {
     $this->table = $table;
     $this->query = new Query();
     $this->driver = $table->getDriver();
 }
Example #3
0
 /**
  * @param Table $table
  */
 public function __construct(Table $table)
 {
     $this->table = $table;
     $this->driver = $table->getDriver();
 }