public function __construct(Model $model, $database = null, $alias = null) { $this->_database = $database ? $database : Database::getInstance(); switch (strtolower($this->_database->getType())) { case 'mysql': $this->_adapter = new MySQL(); break; case 'postgres': $this->_adapter = new Postgres(); break; case 'sqlite3': default: $this->_adapter = new Sqlite3(); break; } $this->_model = $model; $this->_query = new Query(); $this->_query->table = $model->getTableName(); $this->_query->aliasTable = $alias ?: $model::getModelName(); $this->_query->selectType = PDO::FETCH_NUM; $this->_query->selectColumns = array(); }
/** * Constructor for every model class. This is protected as every model * instantiated outside of this class should use the static function * 'create'. */ public function __construct() { $this->_idField = $this->getIdField(); $this->_tableName = $this->getTableName(); if (!static::$_db) { static::$_db = Database::getInstance(); } if (!static::$_schema) { static::$_schema = new Cache(); } }