static function select_db($database_name, $connection = null) { if (self::is_logging()) { Log::notice(__FUNCTION__ . ' ' . $database_name, Log::frame(1)); } return parent::select_db($database_name, $connection); }
/** * Selects the Database * * @param string $database * @return boolean */ function select_db($database) { parent::select_db($database); pg_close($this->link_id); $this->__database = $database; $this->connect(); return true; }
/** * Database exists for the MYSQL user * @param type $database_name * @return boolean */ function database_exists($database_name) { if (empty($database_name)) { return false; } $select_database = Database::select_db($database_name); $show_database = false; $sql = "SHOW DATABASES LIKE '" . addslashes($database_name) . "'"; $result = Database::query($sql); if (Database::num_rows($result)) { $show_database = true; } return $select_database || $show_database; }
} require $phpDigIncCn; // switch to PhpDig DB if ($site_id = remove_engine_entries('http://' . $regs[1] . '/', $path = $regs[2] . '/', $sdisub ? 'index.php?sid=' . $sdisub . '_' : '')) { echo '<table>', "\n"; foreach ($idt as $url => $text) { set_time_limit(30); // again 30 seconds from here on... index_words($site_id, $path, $url, get_first_words($text, $path, $url), get_keywords($text)); } echo '</table>', "\n"; } // possible enhancement: UPDATE spider record for still existing pages if (isset($db)) { //mysql_select_db($_configuration['main_database'], $db); Database::select_db($_configuration['main_database'], $db); } } elseif ($smo == get_lang('Index')) { echo 'Problem! PhpDig connect.php has gone or else URL "' . htmlspecialchars($mdObj->mdo_url, ENT_QUOTES, $charset) . '" is not like "http://xxxx/yyy.../zzz/index.php"'; } } // STATISTICS -----------------------------------------------------------------> echo '<h3>', get_lang('Statistics'), '</h3>', "\n"; $result = $mdStore->mds_get_many('eid', "eid LIKE '" . EID_TYPE . ".%'"); echo get_lang('TotalMDEs'), Database::num_rows($result), "\n"; while ($row = Database::fetch_array($result)) { $eid_id = substr($eid = $row['eid'], TPLEN); if ($dotpos = strpos($eid_id, '.')) { $eid_id = substr($eid_id, 0, $dotpos); } else { $mdtmain[$eid_id] = $mdStore->mds_get($eid);
} } $mysqlStatsDb = $mysqlMainDb; $mysqlUserDb = $mysqlMainDb; // This parameter is needed to run a command line install of Chamilo (needed for Phing) if (!defined('CLI_INSTALLATION')) { include api_get_path(SYS_LANG_PATH).'english/create_course.inc.php'; if ($languageForm != 'english') { include api_get_path(SYS_LANG_PATH).$languageForm.'/create_course.inc.php'; } } Database::select_db($mysqlMainDb) or die(Database::error()); $installation_settings = array(); $installation_settings['{ORGANISATIONNAME}'] = $institutionForm; $installation_settings['{ORGANISATIONURL}'] = $institutionUrlForm; $installation_settings['{CAMPUSNAME}'] = $campusForm; $installation_settings['{PLATFORMLANGUAGE}'] = $languageForm; $installation_settings['{ALLOWSELFREGISTRATION}'] = true_false($allowSelfReg); $installation_settings['{ALLOWTEACHERSELFREGISTRATION}'] = true_false($allowSelfRegProf); $installation_settings['{ADMINLASTNAME}'] = $adminLastName; $installation_settings['{ADMINFIRSTNAME}'] = $adminFirstName; $installation_settings['{ADMINLOGIN}'] = $loginForm; $installation_settings['{ADMINPASSWORD}'] = $passToStore; $installation_settings['{ADMINEMAIL}'] = $emailForm; $installation_settings['{ADMINPHONE}'] = $adminPhoneForm; $installation_settings['{PLATFORM_AUTH_SOURCE}'] = PLATFORM_AUTH_SOURCE;
*/ if ($loglevel > 0) { Log::notice("Now starting migration of scorm tables from global SCORM database"); } $scorm_main = $dbScormForm.'.'.TABLE_SCORM_MAIN; $scorm_item = $dbScormForm.'.'.TABLE_SCORM_SCO_DATA; //$lp_main = Database::get_course_table(TABLE_LEARNPATH_MAIN,$db); $course_pref = $table_prefix; $lp_ids = array(); $lp_item_ids = array(); $lp_item_refs = array(); $lp_course = array(); $lp_course_code = array(); $scorm_lp_paths = array(); // Avoid empty dokeosCourse fields as they potentially break the rest Database::select_db($dbNameForm); $course_main = TABLE_MAIN_COURSE; $sql_crs = "SELECT * FROM $course_main WHERE target_course_code IS NULL"; if ($loglevel > 0) { Log::notice("$sql_crs"); } $res_crs = Database::query($sql_crs); $num = Database::num_rows($res_crs); // Prepare an array that will contain course codes and for each course code a list of lps [by path prefixed by '/'] $scorms = array(); $course_code_swap = ''; $scormdocuments_lps = array(); while ($course_row = Database::fetch_array($res_crs)) { if ($loglevel > 0) { Log::notice("Now dealing with course ".$course_row['code']."..."); } // Check the validity of this new course $my_course_code = $course_row['code'];
<?php require_once "includes/namespace.php"; ?> <body> <?php require_once "topnav.php"; ?> <?php $db = new Database($conf->server(), $conf->username(), $conf->password()); $db->connect(); $db->select_db($conf->dbname()); $results = $query = "select * form users"; ?> <div id="content" class="maincontent"> <div id="expand_collapse_container"> <?php require_once "page_controls.php"; ?> </div><!--end expand collapse--> <ul class="snippet_container"> <li><a href="#" class="snippet-trigger">Create new rails project</a>
break; //found one match with subdir, get out of foreach } // Didn't find any? Now try without subdirs if ($request_url_root == $details['url']) { $_configuration['access_url'] = $details['id']; break; //found one match, get out of foreach } } } else { $_configuration['access_url'] = 1; } // The system has not been designed to use special SQL modes that were introduced since MySQL 5. Database::query("set session sql_mode='';"); if (!Database::select_db($_configuration['main_database'], $database_connection)) { $global_error_code = 5; // Connection to the main Chamilo database is impossible, it might be missing or restricted or its configuration option might be incorrect. require $includePath . '/global_error_message.inc.php'; die; } /* Initialization of the default encodings */ // The platform's character set must be retrieved at this early moment. $sql = "SELECT selected_value FROM settings_current WHERE variable = 'platform_charset';"; $result = Database::query($sql); while ($row = @Database::fetch_array($result)) { $charset = $row[0]; } if (empty($charset)) { $charset = 'UTF-8'; }
} if (Database::num_rows($res) > 0) { $i = 0; $list = array(); while ($row = Database::fetch_array($res)) { $list[] = $row; $i++; } foreach ($list as $row_course) { // Now use the $c_q_list /** * We connect to the right DB first to make sure we can use the queries * without a database name */ if (!$singleDbForm) { // otherwise just use the main one Database::select_db($row_course['db_name']); } Log::notice('Course db ' . $row_course['db_name']); foreach ($c_q_list as $query) { if ($singleDbForm) { $query = preg_replace('/^(UPDATE|ALTER TABLE|CREATE TABLE|DROP TABLE|INSERT INTO|DELETE FROM)\s+(\w*)(.*)$/', "$1 $prefix{$row_course['db_name']}_$2$3", $query); } if ($only_test) { error_log("Database::query(" . $row_course['db_name'] . ",$query)", 0); } else { $res = Database::query($query); if ($log) { error_log("In " . $row_course['db_name'] . ", executed: $query", 0); }
$i = 0; while ($row = Database::fetch_array($res)) { $list[] = $row; $i++; } foreach ($list as $row) { // Now use the $c_q_list /** * We connect to the right DB first to make sure we can use the queries * without a database name */ $prefix_course = $prefix; if ($singleDbForm) { $prefix_course = $prefix . $row['db_name'] . "_"; } else { Database::select_db($row['db_name']); } foreach ($c_q_list as $query) { if ($singleDbForm) { //otherwise just use the main one $query = preg_replace('/^(UPDATE|ALTER TABLE|CREATE TABLE|DROP TABLE|INSERT INTO|DELETE FROM)\s+(\w*)(.*)$/', "$1 $prefix$2$3", $query); } if ($only_test) { error_log("Database::query(" . $row['db_name'] . ",$query)", 0); } else { $res = Database::query($query); if ($log) { error_log("In " . $row['db_name'] . ", executed: $query", 0); } } }