/** * Get an array of all modules * @return array $modules assoc array of all modules */ public static function getModules() { $db = new db(); $db->connect(); $modules = $db->selectAll('modules'); return $modules; }
/** * Checks if any table exist in database * @return boolean */ public static function tablesExists() { $db = new db(); $ret = $db->connect(array('dont_die' => 1)); if ($ret == 'NO_DB_CONN') { return false; } $info = admin::getDbInfo(); if (!$info) { common::echoMessage('No databse url in config.ini'); } if ($info['scheme'] == 'mysql' || $info['scheme'] == 'mysqli') { $rows = $db->selectQuery("SHOW TABLES"); if (empty($rows)) { return false; } return true; } if ($info['scheme'] == 'sqlite') { $sql = "SELECT name FROM sqlite_master WHERE type='table' AND name='modules'"; $rows = $db->selectQuery($sql); if (empty($rows)) { return false; } return true; } }
* * To proper utf8 * * Only testet on my own setup, so backup your database * * There was a few problem with indexes, but they were solved * by running the latin1 -> blob -> utf8 in one query * */ include_once "vendor/autoload.php"; use diversen\conf; use diversen\db; conf::setMainIni('base_path', realpath('.')); conf::loadMainCli(); $db = new db(); $db->connect(); function get_tables_db() { $db = new db(); $rows = $db->selectQuery('show tables'); $tables = array(); foreach ($rows as $table) { $tables[] = array_pop($table); } return $tables; } function get_table_create($table) { $db = new db(); $sql = "DESCRIBE {$table}"; return $db->selectQuery($sql);
/** * Method for setting a profile's template * @param string $template * @return boolean $res */ public function setProfileTemplate($template = null) { $db = new db(); $db->connect(); if (isset($template)) { $this->profileTemplate = $template; } $ini_file = conf::pathHtdocs() . "/templates/{$this->profileTemplate}/{$this->profileTemplate}.ini"; $ini_file_dist = $ini_file . "-dist"; if (conf::isCli()) { if (file_exists($ini_file_dist)) { copy($ini_file_dist, $ini_file); } } $values = array('template' => $this->profileTemplate); return $db->update('settings', $values, 1); }
/** * method for getting all modules from db. This is the first time we * connect to database. * * @return array $ary array with all rows from modules table */ public static function getAllModules() { if (!empty(self::$modules)) { return self::$modules; } static $modules = null; if ($modules) { return $modules; } // we connect here because this should be // the first time we use the database // in the system $db = new db(); $db->connect(); return $db->selectAll('modules'); }