/** * Loads all migrations and their application state from the database. * * @return null */ public function load_migration_state() { $this->migration_state = array(); // prevent errors in case the table does not exist yet $this->db->sql_return_on_error(true); $sql = "SELECT *\n\t\t\tFROM " . $this->migrations_table; $result = $this->db->sql_query($sql); if (!$this->db->get_sql_error_triggered()) { while ($migration = $this->db->sql_fetchrow($result)) { $this->migration_state[$migration['migration_name']] = $migration; $this->migration_state[$migration['migration_name']]['migration_depends_on'] = unserialize($migration['migration_depends_on']); } } $this->db->sql_freeresult($result); $this->db->sql_return_on_error(false); }
/** * Wrapper for running queries to generate user feedback on updates * * @param string $sql SQL query to run on the database * @return mixed Query result from db->sql_query() */ protected function sql_query($sql) { $this->queries[] = $sql; $this->db->sql_return_on_error(true); if ($sql === 'begin') { $result = $this->db->sql_transaction('begin'); } else { if ($sql === 'commit') { $result = $this->db->sql_transaction('commit'); } else { $result = $this->db->sql_query($sql); if ($this->db->get_sql_error_triggered()) { $this->errors[] = array('sql' => $this->db->get_sql_error_sql(), 'code' => $this->db->get_sql_error_returned()); } } } $this->db->sql_return_on_error(false); return $result; }