Browse Source

Feature #272 - Code update according to the recent changes within the Database class - direct use elimination in some places of MySQL-specific functions.

Ivan Tcholakov 15 years ago
parent
commit
3879f51377

+ 2 - 1
main/inc/banner.inc.php

@@ -413,7 +413,8 @@ if (isset ($dokeos_database_connection)) {
 	// if multiple database, prefix table names with the course database name in SQL queries (or no prefix if the table is in
 	// the main database)
 	// (ex. SELECT * FROM `table_from_main_db`  -  SELECT * FROM `courseDB`.`table_from_course_db`)
-	mysql_select_db($_configuration['main_database'], $dokeos_database_connection);
+	//mysql_select_db($_configuration['main_database'], $dokeos_database_connection);
+	Database::select_db($_configuration['main_database'], $dokeos_database_connection);
 }
 ?>
 

+ 10 - 2
main/inc/global.inc.php

@@ -95,7 +95,14 @@ if (empty($_configuration['statistics_database']) && $already_installed) {
 }
 
 // Connect to the server database and select the main dokeos database.
-if (!($dokeos_database_connection = @mysql_connect($_configuration['db_host'], $_configuration['db_user'], $_configuration['db_password']))) {
+//if (!($dokeos_database_connection = @mysql_connect($_configuration['db_host'], $_configuration['db_user'], $_configuration['db_password']))) {
+if (!($dokeos_database_connection = @Database::connect(
+	array(
+		'server' => $_configuration['db_host'],
+		'username' => $_configuration['db_user'],
+		'password' => $_configuration['db_password'],
+		'persistent' => $_configuration['db_persistent_connection'] // When $_configuration['db_persistent_connection'] is set, it is expected to be a boolean type.
+	)))) {
 	$global_error_code = 3;
 	// The database server is not available or credentials are invalid.
 	require $includePath.'/global_error_message.inc.php';
@@ -111,7 +118,8 @@ if (!$_configuration['db_host']) {
 // The system has not been designed to use special SQL modes that were introduced since MySQL 5.
 Database::query("set session sql_mode='';", __FILE__, __LINE__);
 
-if (!mysql_select_db($_configuration['main_database'], $dokeos_database_connection)) {
+//if (!mysql_select_db($_configuration['main_database'], $dokeos_database_connection)) {
+if (!Database::select_db($_configuration['main_database'], $dokeos_database_connection)) {
 	$global_error_code = 5;
 	// Connection to the main Dokeos database is impossible, it might be missing or restricted or its configuration option might be incorrect.
 	require $includePath.'/global_error_message.inc.php';

+ 2 - 1
main/inc/lib/add_course.lib.inc.php

@@ -2072,7 +2072,8 @@ function fill_Db_course($courseDbName, $courseRepository, $language,$default_doc
 	if (file_exists($file_to_include))
 		include (api_get_path(SYS_CODE_PATH) . $file_to_include);
 
-	mysql_select_db("$courseDbName");
+	//mysql_select_db("$courseDbName");
+	Database::select_db("$courseDbName");
 
 	/*
 	==============================================================================

+ 2 - 1
main/inc/lib/export.lib.inc.php

@@ -195,7 +195,8 @@ function backupDatabase($link, $db_name, $structure, $donnees, $format = 'SQL',
 		$error_no['backup'][] = '1';
 		return false;
 	}
-	mysql_select_db($db_name);
+	//mysql_select_db($db_name);
+	Database::select_db($db_name);
 	$format = strtolower($format);
 	$filename = $whereSave.'/courseDbContent.'.$format;
 	$format = strtoupper($format);

+ 2 - 1
main/metadata/importdocs.php

@@ -92,7 +92,8 @@ if (count($idt) && file_exists($phpDigIncCn))
 
     if(isset($db))
     {
-    	mysql_select_db($_configuration['main_database'], $db);  // back to Dokeos
+    	//mysql_select_db($_configuration['main_database'], $db);
+    	Database::select_db($_configuration['main_database'], $db);
     }
 }
 else

+ 2 - 1
main/metadata/importlinks.php

@@ -263,7 +263,8 @@ elseif ($slo == get_lang('Index') && file_exists($phpDigIncCn) && count($mceids)
 
     if(isset($db))
     {
-    	mysql_select_db($_configuration['main_database'], $db);  // back to Dokeos
+    	//mysql_select_db($_configuration['main_database'], $db);
+    	Database::select_db($_configuration['main_database'], $db);
     }
 }
 elseif ($slo == get_lang('Index'))

+ 4 - 1
main/metadata/importmanifest.php

@@ -443,7 +443,10 @@ elseif ($smo == get_lang('Index') && file_exists($phpDigIncCn) &&
     }
     // possible enhancement: UPDATE spider record for still existing pages
 
-    if(isset($db)) mysql_select_db($_configuration['main_database'], $db);  // back to Dokeos
+    if(isset($db)) {
+    	//mysql_select_db($_configuration['main_database'], $db);
+    	Database::select_db($_configuration['main_database'], $db);
+    }
 }
 elseif ($smo == get_lang('Index'))
 {

+ 4 - 2
main/online/online_links.php

@@ -127,7 +127,8 @@ if($_POST['sent'])
 		}
 	}
 
-	mysql_close();
+	//mysql_close();
+	Database::close();
 	header('Location: '.api_get_self());
 	exit();
 }
@@ -139,7 +140,8 @@ if($action == 'delete')
 	$query="DELETE FROM $tbl_online_link WHERE id='$link'";
 	Database::query($query,__FILE__,__LINE__);
 
-	mysql_close();
+	//mysql_close();
+	Database::close();
 	header('Location: '.api_get_self());
 	exit();
 }

+ 2 - 1
main/online/online_streaming.php

@@ -72,7 +72,8 @@ if($_POST['sent'])
 		fclose($fp);
 	}
 
-	mysql_close();
+	//mysql_close();
+	Database::close();
 	header('Location: online_master.php');
 	exit();
 }