public function __construct($options = array()) { parent::__construct($options); if (!$this->class_name) { $this->set_inferred_class_name(); } //infer from class_name if (!$this->foreign_key) { $this->foreign_key = array($this->keyify($this->class_name)); } $this->primary_key = array(Table::load($this->class_name)->pk[0]); }
/** * Returns the {@link Table} object for this model. * * Be sure to call in static scoping: static::table() * * @return Table */ public static function table() { return Table::load(get_called_class()); }
public function __get($name) { if ($name === 'primary_key' && !isset($this->primary_key)) { $this->primary_key = array(Table::load($this->class_name)->pk[0]); } return $this->{$name}; }
/** * Returns the {@link Table} object for this model. * * Be sure to call in static scoping: static::table() * * @return Table */ public static function table() { $t = Table::load(get_called_class()); $called_class = get_called_class(); if (!empty($called_class::$soft_delete_key)) { $t->soft_delete_key = $called_class::$soft_delete_key; } return $t; }
public function primaryKey() { return Table::load($this)->primaryKey(); }
public function __construct($options = array()) { parent::__construct($options); if (!$this->className) { $this->setInferredClassName(); } //infer from class_name if (!$this->foreignKey) { $this->foreignKey = array(Inflector::instance()->keyify($this->className)); } $this->primaryKey = array(Table::load($this->className)->pk[0]); }