public function __construct($db = null) { parent::__construct($db); if (!isset($this->{static::$primary_key})) { $this->initial_data(); } }
/** * The constructor enables you to either create an empty object when no * parameter is passed as $primary_key, or it fetches a row when the parameter * is passed. * * $blog_entry = new Blog_Model(5); * * @param string $primary_key a primary key to search for * */ public function __construct($primary_key = NULL) { parent::__construct($this->_db); $this->_default_data = $this->_data; if ($primary_key !== NULL) { $this->load(db::select_array($this->fields())->where($this->_table_name . '.' . $this->_primary_key, '=', $primary_key)); } elseif ($this->{$this->_primary_key}) { $this->_state = AutoModeler::STATE_LOADED; } }
/** * The constructor enables you to either create an empty object when no * parameter is passed as $id, or it fetches a row when the parameter * is passed. * * $blog_entry = new Blog_Model(5); * * @param string $id an id to search for * */ public function __construct($id = NULL) { parent::__construct($this->_db); if ($id !== NULL) { $this->load(db::select_array($this->fields())->where($this->_table_name.'.id', '=', $id)); } elseif ($this->id) // We loaded this via mysql_result_object { $this->_state = AutoModeler::STATE_LOADED; } }
/** * * @param string $db */ public function __construct($db = NULL) { parent::__construct($db); $this->_table_columns = $this->list_columns(); }