/** * Set up a new model. * @param string $tblName - The name of the table of this model. * @param array $vars - The available collumns in this table. * @param string $primaryKey - The primary key of this table. * @constructor * @access public * @since 1.0.0 */ public function __construct($tblName, $vars, $primaryKey = 'id') { /* Set some defaults. See the documentation to find out what they are. */ $this->db = Database::load(); $this->tblName = $tblName; $this->vars = $vars; $this->primaryKey = $primaryKey; $this->lastStatement = null; $this->dirty = true; $this->filter = []; $this->order = null; $this->perPage = 10; $this->currentPage = 0; $this->total = 0; $this->totalDirty = true; }
/** * Initialize a new row of a model. * @param string $tblName - The name of the table os this model. * @param array $vars - The available variables in this model. * @param string $primaryKey - The primary key of the table of this model. * @param array $values - The initial values of this model. * @param boolean $exists - Wether this row exists in the database. * @param {Model} $parent - The parent model of this row. * @constructor * @access public * @since 1.0.0 */ public function __construct($tblName, $vars, $primaryKey, $values, $exists, $parent) { $this->tblName = $tblName; $this->vars = $vars; $this->primaryKey = $primaryKey; $this->values = $values; $this->originalValues = $values; $this->dirty = false; $this->exists = $exists; $this->parent = $parent; $this->db = Database::load(); }