public function init() { // Parent $fullClassName = get_class($this); $fullClassName = explode("\\", $fullClassName); $this->_table = strtolower($fullClassName[count($fullClassName) - 1]); parent::init(); // $this->app = \IFR\Main\App::get(); // PDO $config = getConfig(CONF_PATH . '/application.xml', getCurrentEnv()); $config = $config->db->toArray(); $this->_db = $this->app->getMysqlDb($config); // Build table $this->_db->exec("DROP TABLE IF EXISTS {$this->_table};"); $filePath = sprintf('./resources/sql/%s.sql', $this->_table); assertTrue(file_exists($filePath), "SQL file '{$filePath}' does not exist"); $this->_db->exec(file_get_contents($filePath)); // Build settings $columns = array_merge(self::$DEFAULT_COLUMNS, $this->getColumnsDefinition()); foreach ($columns as $name => $column) { $this->setColumns($name)->schemaColumnSet($name, $column); } }