/** * 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; } } }
/** * 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(); }
/** * @param Table $table */ public function __construct(Table $table) { $this->table = $table; $this->driver = $table->getDriver(); }