diff --git a/main/exercice/mark_free_answer.php b/main/exercice/mark_free_answer.php
index ab402a6328..a747ac20e1 100755
--- a/main/exercice/mark_free_answer.php
+++ b/main/exercice/mark_free_answer.php
@@ -182,7 +182,7 @@ if($action == 'mark'){
$res = Database::query($sql);
$my_msg = get_lang('MarkInserted');
}
- //$Database::query($sql);
+ //Database::query($sql);
//return 0;
}
}else{
diff --git a/main/inc/lib/document.lib.php b/main/inc/lib/document.lib.php
index 9033bf3330..5c9d843dc1 100755
--- a/main/inc/lib/document.lib.php
+++ b/main/inc/lib/document.lib.php
@@ -540,7 +540,7 @@ class DocumentManager {
if ($result && Database::num_rows($result) != 0)
{
while ($row = Database::fetch_array($result,'ASSOC'))
- //while ($row = Database::fetch_array($result,MYSQL_NUM))
+ //while ($row = Database::fetch_array($result, 'NUM'))
{
if($row['filetype']=='file' && pathinfo($row['path'],PATHINFO_EXTENSION)=='html'){
diff --git a/main/install/install_functions.inc.php b/main/install/install_functions.inc.php
index 5255451d37..59fba59608 100755
--- a/main/install/install_functions.inc.php
+++ b/main/install/install_functions.inc.php
@@ -1106,18 +1106,17 @@ function display_after_install_message($installType, $nbr_courses) {
function test_db_connect($dbHostForm, $dbUsernameForm, $dbPassForm, $singleDbForm, $dbPrefixForm) {
$dbConnect = -1;
if ($singleDbForm == 1) {
- if(@mysql_connect($dbHostForm, $dbUsernameForm, $dbPassForm) !== false) {
+ if (@Database::connect(array('server' => $dbHostForm, 'username' => $dbUsernameForm, 'password' => $dbPassForm)) !== false) {
$dbConnect = 1;
} else {
$dbConnect = -1;
}
} elseif ($singleDbForm == 0) {
- $res = @mysql_connect($dbHostForm, $dbUsernameForm, $dbPassForm);
- if ($res !== false) {
- @mysql_query("set session sql_mode='';"); // Disabling special SQL modes (MySQL 5)
- $multipleDbCheck = @mysql_query("CREATE DATABASE ".$dbPrefixForm."test_chamilo_connection");
+ if (@Database::connect(array('server' => $dbHostForm, 'username' => $dbUsernameForm, 'password' => $dbPassForm)) !== false) {
+ @Database::query("set session sql_mode='';"); // Disabling special SQL modes (MySQL 5)
+ $multipleDbCheck = @Database::query("CREATE DATABASE ".$dbPrefixForm."test_chamilo_connection");
if ($multipleDbCheck !== false) {
- $multipleDbCheck = @mysql_query("DROP DATABASE IF EXISTS ".$dbPrefixForm."test_chamilo_connection");
+ $multipleDbCheck = @Database::query("DROP DATABASE IF EXISTS ".$dbPrefixForm."test_chamilo_connection");
if ($multipleDbCheck !== false) {
$dbConnect = 1;
} else {
diff --git a/main/install/update-db-1.6.x-1.8.0.inc.php b/main/install/update-db-1.6.x-1.8.0.inc.php
index 3fcc5ff449..caf8f0f15a 100755
--- a/main/install/update-db-1.6.x-1.8.0.inc.php
+++ b/main/install/update-db-1.6.x-1.8.0.inc.php
@@ -85,12 +85,13 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
if (empty ($dbScormForm) || $dbScormForm == 'mysql' || $dbScormForm == $dbPrefixForm) {
$dbScormForm = $dbPrefixForm.'scorm';
}
- $res = @mysql_connect($dbHostForm, $dbUsernameForm, $dbPassForm);
+
+ $res = @Database::connect(array('server' => $dbHostForm, 'username' => $dbUsernameForm, 'password' => $dbPassForm));
//if error on connection to the database, show error and exit
if ($res === false) {
- //$no = mysql_errno();
- //$msg = mysql_error();
+ //$no = Database::errno();
+ //$msg = Database::error();
//echo '
['.$no.'] - '.$msg.'
';
echo get_lang('DBServerDoesntWorkOrLoginPassIsWrong').'.
@@ -105,13 +106,10 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
exit ();
}
- @mysql_query("set session sql_mode='';"); // Disabling special SQL modes (MySQL 5)
+ @Database::query("set session sql_mode='';"); // Disabling special SQL modes (MySQL 5)
+
+ $dblist = Database::get_databases();
- $dblistres = mysql_list_dbs();
- $dblist = array();
- while ($row = mysql_fetch_object($dblistres)) {
- $dblist[] = $row->Database;
- }
/*
-----------------------------------------------------------
Normal upgrade procedure:
@@ -153,12 +151,12 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
} elseif (!in_array($dbNameForm, $dblist)) {
error_log('Database '.$dbNameForm.' was not found, skipping', 0);
} else {
- mysql_select_db($dbNameForm);
+ Database::select_db($dbNameForm);
foreach ($m_q_list as $query) {
if ($only_test) {
- error_log("mysql_query($dbNameForm,$query)", 0);
+ error_log("Database::query($dbNameForm,$query)", 0);
} else {
- $res = mysql_query($query);
+ $res = Database::query($query);
if ($log) {
error_log("In $dbNameForm, executed: $query", 0);
}
@@ -175,17 +173,17 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
* We connect to the right DB first to make sure we can use the queries
* without a database name
*/
- if (strlen($dbStatsForm) > 40){
+ if (strlen($dbStatsForm) > 40) {
error_log('Database name '.$dbStatsForm.' is too long, skipping', 0);
- } elseif (!in_array($dbStatsForm,$dblist)){
+ } elseif (!in_array($dbStatsForm, $dblist)) {
error_log('Database '.$dbStatsForm.' was not found, skipping', 0);
} else {
- mysql_select_db($dbStatsForm);
+ Database::select_db($dbStatsForm);
foreach($s_q_list as $query) {
if ($only_test) {
- error_log("mysql_query($dbStatsForm,$query)", 0);
+ error_log("Database::query($dbStatsForm,$query)", 0);
} else {
- $res = mysql_query($query);
+ $res = Database::query($query);
if ($log) {
error_log("In $dbStatsForm, executed: $query", 0);
}
@@ -204,16 +202,16 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
*/
if (strlen($dbUserForm) > 40) {
error_log('Database name '.$dbUserForm.' is too long, skipping', 0);
- } elseif (!in_array($dbUserForm, $dblist)){
+ } elseif (!in_array($dbUserForm, $dblist)) {
error_log('Database '.$dbUserForm.' was not found, skipping', 0);
} else {
- mysql_select_db($dbUserForm);
- foreach ($u_q_list as $query){
- if ($only_test){
- error_log("mysql_query($dbUserForm,$query)", 0);
+ Database::select_db($dbUserForm);
+ foreach ($u_q_list as $query) {
+ if ($only_test) {
+ error_log("Database::query($dbUserForm,$query)", 0);
error_log("In $dbUserForm, executed: $query", 0);
} else {
- $res = mysql_query($query);
+ $res = Database::query($query);
}
}
}
@@ -249,14 +247,14 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
} elseif (!in_array($dbNameForm, $dblist)) {
error_log('Database '.$dbNameForm.' was not found, skipping', 0);
} else {
- mysql_select_db($dbNameForm);
- $res = mysql_query("SELECT code,db_name,directory,course_language FROM course WHERE target_course_code IS NULL");
+ Database::select_db($dbNameForm);
+ $res = Database::query("SELECT code,db_name,directory,course_language FROM course WHERE target_course_code IS NULL");
if ($res === false) { die('Error while querying the courses list in update_db-1.6.x-1.8.0.inc.php'); }
- if (mysql_num_rows($res) > 0) {
+ if (Database::num_rows($res) > 0) {
$i = 0;
$list = array();
- //while( ($i < MAX_COURSE_TRANSFER) && ($row = mysql_fetch_array($res)))
- while($row = mysql_fetch_array($res)) {
+ //while( ($i < MAX_COURSE_TRANSFER) && ($row = Database::fetch_array($res)))
+ while($row = Database::fetch_array($res)) {
$list[] = $row;
$i++;
}
@@ -267,7 +265,7 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
* without a database name
*/
if (!$singleDbForm) { //otherwise just use the main one
- mysql_select_db($row_course['db_name']);
+ Database::select_db($row_course['db_name']);
}
foreach($c_q_list as $query) {
@@ -276,9 +274,9 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
}
if ($only_test) {
- error_log("mysql_query(".$row_course['db_name'].",$query)", 0);
+ error_log("Database::query(".$row_course['db_name'].",$query)", 0);
} else {
- $res = mysql_query($query);
+ $res = Database::query($query);
if ($log) {
error_log("In ".$row_course['db_name'].", executed: $query", 0);
}
@@ -292,8 +290,8 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
" FROM $dbNameForm.user u, $dbNameForm.course_rel_user cu " .
" WHERE cu.course_code = '".$row_course['code']."' " .
" AND u.user_id = cu.user_id";
- $res_uc = mysql_query($sql_uc);
- while($user_row = mysql_fetch_array($res_uc)) {
+ $res_uc = Database::query($sql_uc);
+ while($user_row = Database::fetch_array($res_uc)) {
$users_list[$user_row['fn'].' '.$user_row['ln']] = $user_row['ui'];
}
@@ -310,54 +308,54 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
}
$sql_orig = "SELECT * FROM ".$prefix_course."bb_categories";
- $res_orig = mysql_query($sql_orig);
+ $res_orig = Database::query($sql_orig);
$order = 1;
- while ($row = mysql_fetch_array($res_orig)) {
+ while ($row = Database::fetch_array($res_orig)) {
$myorder = (empty($row['cat_order']) ? $order : $row['cat_order']);
$sql = "INSERT INTO ".$prefix_course."forum_category " .
"(cat_id,cat_title,cat_comment,cat_order,locked) VALUES " .
- "('".$row['cat_id']."','".mysql_real_escape_string($row['cat_title'])."','','".$myorder."',0)";
- $res = mysql_query($sql);
- $lastcatid = mysql_insert_id();
+ "('".$row['cat_id']."','".Database::escape_string($row['cat_title'])."','','".$myorder."',0)";
+ $res = Database::query($sql);
+ $lastcatid = Database::insert_id();
//error_log($sql,0);
$order ++;
//add item_property - forum categories were not put into item_properties before
$sql = "INSERT INTO ".$prefix_course."item_property (tool,insert_user_id,ref,lastedit_type,lastedit_user_id,visibility) " .
"VALUES ('forum_category','1','$lastcatid','ForumCategoryAdded','1','1')";
- $res = mysql_query($sql);
+ $res = Database::query($sql);
//error_log($sql,0);
}
$sql_orig = "SELECT * FROM ".$prefix_course."bb_forums ORDER BY forum_last_post_id desc";
- $res_orig = mysql_query($sql_orig);
+ $res_orig = Database::query($sql_orig);
$order = 1;
- while ($row = mysql_fetch_array($res_orig)) {
+ while ($row = Database::fetch_array($res_orig)) {
$sql = "INSERT INTO ".$prefix_course."forum_forum " .
"(forum_id,forum_category,allow_edit,forum_comment," .
"forum_title," .
"forum_last_post, forum_threads," .
"locked, forum_posts, " .
"allow_new_threads, forum_order) VALUES " .
- "('".$row['forum_id']."','".$row['cat_id']."',1,'".mysql_real_escape_string($row['forum_desc'])."'," .
- "'".mysql_real_escape_string($row['forum_name'])."'," .
+ "('".$row['forum_id']."','".$row['cat_id']."',1,'".Database::escape_string($row['forum_desc'])."'," .
+ "'".Database::escape_string($row['forum_name'])."'," .
"'".$row['forum_last_post_id']."','".$row['forum_topics']."'," .
"0,'".$row['forum_posts']."'," .
"1,$order)";
//error_log($sql,0);
- $res = mysql_query($sql);
- $lastforumid = mysql_insert_id();
+ $res = Database::query($sql);
+ $lastforumid = Database::insert_id();
$order++;
//add item_property - forums were not put into item_properties before
$sql = "INSERT INTO ".$prefix_course."item_property (tool,insert_user_id,ref,lastedit_type,lastedit_user_id,visibility) " .
"VALUES ('forum','1','$lastforumid','ForumAdded','1','1')";
- $res = mysql_query($sql);
+ $res = Database::query($sql);
//error_log($sql,0);
}
$sql_orig = "SELECT * FROM ".$prefix_course."bb_topics";
- $res_orig = mysql_query($sql_orig);
- while ($row = mysql_fetch_array($res_orig)) {
+ $res_orig = Database::query($sql_orig);
+ while ($row = Database::fetch_array($res_orig)) {
$name = $row['prenom'].' '.$row['nom'];
//check if user id is reusable
if ($row['topic_poster'] <= 1) {
@@ -369,30 +367,30 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
}
//convert time from varchar to datetime
$time = $row['topic_time'];
- $name = mysql_real_escape_string($name);
+ $name = Database::escape_string($name);
$sql = "INSERT INTO ".$prefix_course."forum_thread " .
"(thread_id,forum_id,thread_poster_id," .
"locked,thread_replies,thread_sticky,thread_title," .
"thread_poster_name, thread_date, thread_last_post," .
"thread_views) VALUES " .
"('".$row['topic_id']."','".$row['forum_id']."','".$poster_id."'," .
- "0,'".$row['topic_replies']."',0,'".mysql_real_escape_string($row['topic_title'])."'," .
+ "0,'".$row['topic_replies']."',0,'".Database::escape_string($row['topic_title'])."'," .
"'$name','$time','".$row['topic_last_post_id']."'," .
"'".$row['topic_views']."')";
//error_log($sql,0);
- $res = mysql_query($sql);
- $lastthreadid = mysql_insert_id();
+ $res = Database::query($sql);
+ $lastthreadid = Database::insert_id();
//add item_property - forum threads were not put into item_properties before
$sql = "INSERT INTO ".$prefix_course."item_property (tool,insert_user_id,ref,lastedit_type,lastedit_user_id,visibility) " .
"VALUES ('forum_thread','1','$lastthreadid','ForumThreadAdded','1','1')";
- $res = mysql_query($sql);
+ $res = Database::query($sql);
//error_log($sql,0);
}
$sql_orig = "SELECT * FROM ".$prefix_course."bb_posts bp, ".$prefix_course."bb_posts_text bpt WHERE bp.post_id = bpt.post_id";
- $res_orig = mysql_query($sql_orig);
- while ($row = mysql_fetch_array($res_orig)) {
+ $res_orig = Database::query($sql_orig);
+ while ($row = Database::fetch_array($res_orig)) {
$name = $row['prenom'].' '.$row['nom'];
//check if user id is reusable
if ($row['poster_id'] <= 0 ) {
@@ -404,7 +402,7 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
}
//convert time from varchar to datetime
$time = $row['post_time'];
- $name = mysql_real_escape_string($name);
+ $name = Database::escape_string($name);
$sql = "INSERT INTO ".$prefix_course."forum_post " .
"(post_id,forum_id,thread_id," .
"poster_id,post_parent_id,visible, " .
@@ -412,28 +410,28 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
"post_date, post_notification) VALUES " .
"('".$row['post_id']."','".$row['forum_id']."','".$row['topic_id']."'," .
"'".$poster_id."','".$row['parent_id']."',1," .
- "'".mysql_real_escape_string($row['post_title'])."','$name', '".mysql_real_escape_string($row['post_text'])."'," .
+ "'".Database::escape_string($row['post_title'])."','$name', '".Database::escape_string($row['post_text'])."'," .
"'$time',0)";
//error_log($sql,0);
- $res = mysql_query($sql);
- $lastpostid = mysql_insert_id();
+ $res = Database::query($sql);
+ $lastpostid = Database::insert_id();
//add item_property - forum threads were not put into item_properties before
$sql = "INSERT INTO ".$prefix_course."item_property(tool,insert_user_id,ref,lastedit_type,lastedit_user_id,visibility) " .
"VALUES ('forum_post','1','$lastpostid','ForumPostAdded','1','1')";
- $res = mysql_query($sql);
+ $res = Database::query($sql);
//error_log($sql,0);
}
unset($users_list);
$sql_orig = "SELECT id, tutor_id FROM ".$prefix_course."group_info";
- $res_orig = mysql_query($sql_orig);
+ $res_orig = Database::query($sql_orig);
$order = 1;
- while ($row = mysql_fetch_array($res_orig)) {
+ while ($row = Database::fetch_array($res_orig)) {
$sql = "INSERT INTO ".$prefix_course."group_rel_tutor " .
"(user_id,group_id) VALUES " .
"('".$row['tutor_id']."','".$row['id']."')";
- $res = mysql_query($sql);
+ $res = Database::query($sql);
}
}
}
@@ -465,12 +463,12 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
} elseif (!in_array($dbNameForm, $dblist)) {
error_log('Database '.$dbNameForm.' was not found, skipping', 0);
} else {
- mysql_select_db($dbNameForm);
+ Database::select_db($dbNameForm);
foreach ($m_q_list as $query) {
if ($only_test){
- error_log("mysql_query($dbNameForm,$query)", 0);
+ error_log("Database::query($dbNameForm,$query)", 0);
} else {
- $res = mysql_query($query);
+ $res = Database::query($query);
if ($log) {
error_log("In $dbNameForm, executed: $query", 0);
}
@@ -492,12 +490,12 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
} elseif (!in_array($dbNameForm, $dblist)){
error_log('Database '.$dbNameForm.' was not found, skipping', 0);
} else {
- mysql_select_db($dbStatsForm);
+ Database::select_db($dbStatsForm);
foreach ($s_q_list as $query) {
if ($only_test) {
- error_log("mysql_query($dbStatsForm,$query)", 0);
+ error_log("Database::query($dbStatsForm,$query)", 0);
} else {
- $res = mysql_query($query);
+ $res = Database::query($query);
if ($log) {
error_log("In $dbStatsForm, executed: $query", 0);
}
@@ -516,15 +514,15 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
*/
if (strlen($dbUserForm) > 40) {
error_log('Database name '.$dbUserForm.' is too long, skipping', 0);
- } elseif (!in_array($dbUserForm,$dblist)) {
+ } elseif (!in_array($dbUserForm, $dblist)) {
error_log('Database '.$dbUserForm.' was not found, skipping', 0);
} else {
- mysql_select_db($dbUserForm);
+ Database::select_db($dbUserForm);
foreach ($u_q_list as $query) {
if ($only_test) {
- error_log("mysql_query($dbUserForm,$query)", 0);
+ error_log("Database::query($dbUserForm,$query)", 0);
} else {
- $res = mysql_query($query);
+ $res = Database::query($query);
if ($log) {
error_log("In $dbUserForm, executed: $query", 0);
}
@@ -541,16 +539,16 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
//get the courses list
if (strlen($dbNameForm) > 40) {
error_log('Database name '.$dbNameForm.' is too long, skipping', 0);
- } elseif (!in_array($dbNameForm,$dblist)) {
+ } elseif (!in_array($dbNameForm, $dblist)) {
error_log('Database '.$dbNameForm.' was not found, skipping', 0);
} else {
- mysql_select_db($dbNameForm);
- $res = mysql_query("SELECT code,db_name,directory,course_language FROM course WHERE target_course_code IS NULL");
+ Database::select_db($dbNameForm);
+ $res = Database::query("SELECT code,db_name,directory,course_language FROM course WHERE target_course_code IS NULL");
if ($res === false) { die('Error while querying the courses list in update_db-1.6.x-1.8.0.inc.php'); }
- if (mysql_num_rows($res) > 0) {
+ if (Database::num_rows($res) > 0) {
$i = 0;
- //while( ($i < MAX_COURSE_TRANSFER) && ($row = mysql_fetch_array($res)))
- while ($row = mysql_fetch_array($res)) {
+ //while( ($i < MAX_COURSE_TRANSFER) && ($row = Database::fetch_array($res)))
+ while ($row = Database::fetch_array($res)) {
$list[] = $row;
$i++;
}
@@ -564,7 +562,7 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
if ($singleDbForm) {
$prefix_course = $prefix.$row['db_name']."_";
} else {
- mysql_select_db($row['db_name']);
+ Database::select_db($row['db_name']);
}
foreach($c_q_list as $query) {
@@ -572,9 +570,9 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
$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("mysql_query(".$row['db_name'].",$query)", 0);
+ error_log("Database::query(".$row['db_name'].",$query)", 0);
} else {
- $res = mysql_query($query);
+ $res = Database::query($query);
if ($log) {
error_log("In ".$row['db_name'].", executed: $query", 0);
}
diff --git a/main/install/update-db-1.8.0-1.8.2.inc.php b/main/install/update-db-1.8.0-1.8.2.inc.php
index 84447ca8b3..63535e5057 100755
--- a/main/install/update-db-1.8.0-1.8.2.inc.php
+++ b/main/install/update-db-1.8.0-1.8.2.inc.php
@@ -84,12 +84,13 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
if (empty($dbScormForm) || $dbScormForm == 'mysql' || $dbScormForm == $dbPrefixForm) {
$dbScormForm = $dbPrefixForm.'scorm';
}
- $res = @mysql_connect($dbHostForm, $dbUsernameForm, $dbPassForm);
+
+ $res = @Database::connect(array('server' => $dbHostForm, 'username' => $dbUsernameForm, 'password' => $dbPassForm));
//if error on connection to the database, show error and exit
if ($res === false) {
- //$no = mysql_errno();
- //$msg = mysql_error();
+ //$no = Database::errno();
+ //$msg = Database::error();
//echo '
['.$no.'] - '.$msg.'
';
echo get_lang('DBServerDoesntWorkOrLoginPassIsWrong').'.
@@ -104,13 +105,10 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
exit ();
}
- @mysql_query("set session sql_mode='';"); // Disabling special SQL modes (MySQL 5)
+ @Database::query("set session sql_mode='';"); // Disabling special SQL modes (MySQL 5)
+
+ $dblist = Database::get_databases();
- $dblistres = mysql_list_dbs();
- $dblist = array();
- while ($row = mysql_fetch_object($dblistres)) {
- $dblist[] = $row->Database;
- }
/*
-----------------------------------------------------------
Normal upgrade procedure:
@@ -150,12 +148,12 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
} elseif (!in_array($dbNameForm,$dblist)) {
error_log('Database '.$dbNameForm.' was not found, skipping', 0);
} else {
- mysql_select_db($dbNameForm);
+ Database::select_db($dbNameForm);
foreach ($m_q_list as $query) {
if ($only_test) {
- error_log("mysql_query($dbNameForm,$query)", 0);
+ error_log("Database::query($dbNameForm,$query)", 0);
} else {
- $res = mysql_query($query);
+ $res = Database::query($query);
if ($log) {
error_log("In $dbNameForm, executed: $query", 0);
}
@@ -178,12 +176,12 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
} elseif (!in_array($dbStatsForm, $dblist)) {
error_log('Database '.$dbStatsForm.' was not found, skipping', 0);
} else {
- mysql_select_db($dbStatsForm);
+ Database::select_db($dbStatsForm);
foreach ($s_q_list as $query) {
if ($only_test) {
- error_log("mysql_query($dbStatsForm,$query)", 0);
+ error_log("Database::query($dbStatsForm,$query)", 0);
} else {
- $res = mysql_query($query);
+ $res = Database::query($query);
if ($log) {
error_log("In $dbStatsForm, executed: $query", 0);
}
@@ -204,13 +202,13 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
} elseif (!in_array($dbUserForm,$dblist)) {
error_log('Database '.$dbUserForm.' was not found, skipping', 0);
} else {
- mysql_select_db($dbUserForm);
+ Database::select_db($dbUserForm);
foreach ($u_q_list as $query) {
if ($only_test) {
- error_log("mysql_query($dbUserForm,$query)", 0);
+ error_log("Database::query($dbUserForm,$query)", 0);
error_log("In $dbUserForm, executed: $query", 0);
} else {
- $res = mysql_query($query);
+ $res = Database::query($query);
}
}
}
@@ -244,14 +242,14 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
} elseif (!in_array($dbNameForm,$dblist)) {
error_log('Database '.$dbNameForm.' was not found, skipping', 0);
} else {
- mysql_select_db($dbNameForm);
- $res = mysql_query("SELECT code,db_name,directory,course_language FROM course WHERE target_course_code IS NULL");
+ Database::select_db($dbNameForm);
+ $res = Database::query("SELECT code,db_name,directory,course_language FROM course WHERE target_course_code IS NULL");
if ($res === false) { die('Error while querying the courses list in update_db-1.8.0-1.8.2.inc.php'); }
- if (mysql_num_rows($res) > 0) {
+ if (Database::num_rows($res) > 0) {
$i = 0;
$list = array();
- //while( ($i < MAX_COURSE_TRANSFER) && ($row = mysql_fetch_array($res)))
- while($row = mysql_fetch_array($res)) {
+ //while( ($i < MAX_COURSE_TRANSFER) && ($row = Database::fetch_array($res)))
+ while($row = Database::fetch_array($res)) {
$list[] = $row;
$i++;
}
@@ -262,7 +260,7 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
* without a database name
*/
if (!$singleDbForm) { //otherwise just use the main one
- mysql_select_db($row_course['db_name']);
+ Database::select_db($row_course['db_name']);
}
foreach($c_q_list as $query) {
@@ -271,9 +269,9 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
}
if ($only_test) {
- error_log("mysql_query(".$row_course['db_name'].",$query)", 0);
+ error_log("Database::query(".$row_course['db_name'].",$query)", 0);
} else {
- $res = mysql_query($query);
+ $res = Database::query($query);
if ($log) {
error_log("In ".$row_course['db_name'].", executed: $query", 0);
}
diff --git a/main/install/update-db-1.8.2-1.8.3.inc.php b/main/install/update-db-1.8.2-1.8.3.inc.php
index 483efb1b81..1a82b38d1b 100755
--- a/main/install/update-db-1.8.2-1.8.3.inc.php
+++ b/main/install/update-db-1.8.2-1.8.3.inc.php
@@ -84,12 +84,13 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
if (empty ($dbScormForm) || $dbScormForm == 'mysql' || $dbScormForm == $dbPrefixForm) {
$dbScormForm = $dbPrefixForm.'scorm';
}
- $res = @mysql_connect($dbHostForm, $dbUsernameForm, $dbPassForm);
+
+ $res = @Database::connect(array('server' => $dbHostForm, 'username' => $dbUsernameForm, 'password' => $dbPassForm));
//if error on connection to the database, show error and exit
if ($res === false) {
- //$no = mysql_errno();
- //$msg = mysql_error();
+ //$no = Database::errno();
+ //$msg = Database::error();
//echo '
['.$no.'] - '.$msg.'
';
echo get_lang('DBServerDoesntWorkOrLoginPassIsWrong').'.
' .
@@ -103,13 +104,10 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
exit ();
}
- @mysql_query("set session sql_mode='';"); // Disabling special SQL modes (MySQL 5)
+ @Database::query("set session sql_mode='';"); // Disabling special SQL modes (MySQL 5)
+
+ $dblist = Database::get_databases();
- $dblistres = mysql_list_dbs();
- $dblist = array();
- while ($row = mysql_fetch_object($dblistres)) {
- $dblist[] = $row->Database;
- }
/*
-----------------------------------------------------------
Normal upgrade procedure:
@@ -150,12 +148,12 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
} elseif (!in_array($dbNameForm,$dblist)) {
error_log('Database '.$dbNameForm.' was not found, skipping', 0);
} else {
- mysql_select_db($dbNameForm);
+ Database::select_db($dbNameForm);
foreach ($m_q_list as $query) {
if ($only_test) {
- error_log("mysql_query($dbNameForm,$query)", 0);
+ error_log("Database::query($dbNameForm,$query)", 0);
} else {
- $res = mysql_query($query);
+ $res = Database::query($query);
if ($log) {
error_log("In $dbNameForm, executed: $query", 0);
}
@@ -178,12 +176,12 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
} elseif (!in_array($dbStatsForm, $dblist)) {
error_log('Database '.$dbStatsForm.' was not found, skipping', 0);
} else {
- mysql_select_db($dbStatsForm);
+ Database::select_db($dbStatsForm);
foreach ($s_q_list as $query) {
if ($only_test) {
- error_log("mysql_query($dbStatsForm,$query)", 0);
+ error_log("Database::query($dbStatsForm,$query)", 0);
} else {
- $res = mysql_query($query);
+ $res = Database::query($query);
if ($log) {
error_log("In $dbStatsForm, executed: $query", 0);
}
@@ -204,13 +202,13 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
} elseif (!in_array($dbUserForm, $dblist)) {
error_log('Database '.$dbUserForm.' was not found, skipping', 0);
} else {
- mysql_select_db($dbUserForm);
+ Database::select_db($dbUserForm);
foreach ($u_q_list as $query) {
if ($only_test) {
- error_log("mysql_query($dbUserForm, $query)", 0);
+ error_log("Database::query($dbUserForm, $query)", 0);
error_log("In $dbUserForm, executed: $query", 0);
} else {
- $res = mysql_query($query);
+ $res = Database::query($query);
}
}
}
@@ -244,14 +242,14 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
} elseif (!in_array($dbNameForm, $dblist)) {
error_log('Database '.$dbNameForm.' was not found, skipping', 0);
} else {
- mysql_select_db($dbNameForm);
- $res = mysql_query("SELECT code,db_name,directory,course_language FROM course WHERE target_course_code IS NULL");
+ Database::select_db($dbNameForm);
+ $res = Database::query("SELECT code,db_name,directory,course_language FROM course WHERE target_course_code IS NULL");
if ($res === false) { die('Error while querying the courses list in update_db-1.8.2-1.8.3.inc.php'); }
- if (mysql_num_rows($res) > 0) {
+ if (Database::num_rows($res) > 0) {
$i = 0;
$list = array();
- //while( ($i < MAX_COURSE_TRANSFER) && ($row = mysql_fetch_array($res)))
- while ($row = mysql_fetch_array($res)) {
+ //while( ($i < MAX_COURSE_TRANSFER) && ($row = Database::fetch_array($res)))
+ while ($row = Database::fetch_array($res)) {
$list[] = $row;
$i++;
}
@@ -262,7 +260,7 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
* without a database name
*/
if (!$singleDbForm) { //otherwise just use the main one
- mysql_select_db($row_course['db_name']);
+ Database::select_db($row_course['db_name']);
}
foreach ($c_q_list as $query) {
@@ -271,9 +269,9 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
}
if ($only_test) {
- error_log("mysql_query(".$row_course['db_name'].",$query)", 0);
+ error_log("Database::query(".$row_course['db_name'].",$query)", 0);
} else {
- $res = mysql_query($query);
+ $res = Database::query($query);
if ($log) {
error_log("In ".$row_course['db_name'].", executed: $query", 0);
}
diff --git a/main/install/update-db-1.8.3-1.8.4.inc.php b/main/install/update-db-1.8.3-1.8.4.inc.php
index da15cfad5d..524c20c77c 100755
--- a/main/install/update-db-1.8.3-1.8.4.inc.php
+++ b/main/install/update-db-1.8.3-1.8.4.inc.php
@@ -83,12 +83,13 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
if (empty ($dbScormForm) || $dbScormForm == 'mysql' || $dbScormForm == $dbPrefixForm) {
$dbScormForm = $dbPrefixForm.'scorm';
}
- $res = @mysql_connect($dbHostForm, $dbUsernameForm, $dbPassForm);
+
+ $res = @Database::connect(array('server' => $dbHostForm, 'username' => $dbUsernameForm, 'password' => $dbPassForm));
//if error on connection to the database, show error and exit
if ($res === false) {
- //$no = mysql_errno();
- //$msg = mysql_error();
+ //$no = Database::errno();
+ //$msg = Database::error();
//echo '
['.$no.'] - '.$msg.'
';
echo get_lang('DBServerDoesntWorkOrLoginPassIsWrong').'.
' .
@@ -102,13 +103,10 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
exit ();
}
- @mysql_query("set session sql_mode='';"); // Disabling special SQL modes (MySQL 5)
+ @Database::query("set session sql_mode='';"); // Disabling special SQL modes (MySQL 5)
+
+ $dblist = Database::get_databases();
- $dblistres = mysql_list_dbs();
- $dblist = array();
- while ($row = mysql_fetch_object($dblistres)) {
- $dblist[] = $row->Database;
- }
/*
-----------------------------------------------------------
Normal upgrade procedure:
@@ -149,12 +147,12 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
} elseif (!in_array($dbNameForm, $dblist)) {
error_log('Database '.$dbNameForm.' was not found, skipping', 0);
} else {
- mysql_select_db($dbNameForm);
+ Database::select_db($dbNameForm);
foreach ($m_q_list as $query) {
if ($only_test) {
- error_log("mysql_query($dbNameForm, $query)", 0);
+ error_log("Database::query($dbNameForm, $query)", 0);
} else {
- $res = mysql_query($query);
+ $res = Database::query($query);
if ($log) {
error_log("In $dbNameForm, executed: $query", 0);
}
@@ -177,12 +175,12 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
} elseif (!in_array($dbStatsForm, $dblist)) {
error_log('Database '.$dbStatsForm.' was not found, skipping', 0);
} else {
- mysql_select_db($dbStatsForm);
+ Database::select_db($dbStatsForm);
foreach ($s_q_list as $query) {
if ($only_test) {
- error_log("mysql_query($dbStatsForm,$query)", 0);
+ error_log("Database::query($dbStatsForm,$query)", 0);
} else {
- $res = mysql_query($query);
+ $res = Database::query($query);
if ($log) {
error_log("In $dbStatsForm, executed: $query", 0);
}
@@ -203,13 +201,13 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
} elseif (!in_array($dbUserForm, $dblist)){
error_log('Database '.$dbUserForm.' was not found, skipping', 0);
} else {
- mysql_select_db($dbUserForm);
+ Database::select_db($dbUserForm);
foreach ($u_q_list as $query) {
if ($only_test) {
- error_log("mysql_query($dbUserForm,$query)", 0);
+ error_log("Database::query($dbUserForm,$query)", 0);
error_log("In $dbUserForm, executed: $query", 0);
} else {
- $res = mysql_query($query);
+ $res = Database::query($query);
}
}
}
@@ -243,14 +241,14 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
} elseif (!in_array($dbNameForm, $dblist)) {
error_log('Database '.$dbNameForm.' was not found, skipping', 0);
} else {
- mysql_select_db($dbNameForm);
- $res = mysql_query("SELECT code,db_name,directory,course_language FROM course WHERE target_course_code IS NULL");
+ Database::select_db($dbNameForm);
+ $res = Database::query("SELECT code,db_name,directory,course_language FROM course WHERE target_course_code IS NULL");
if ($res === false) { die('Error while querying the courses list in update_db-1.8.3-1.8.4.inc.php'); }
- if (mysql_num_rows($res) > 0) {
+ if (Database::num_rows($res) > 0) {
$i = 0;
$list = array();
- //while( ($i < MAX_COURSE_TRANSFER) && ($row = mysql_fetch_array($res)))
- while ($row = mysql_fetch_array($res)) {
+ //while( ($i < MAX_COURSE_TRANSFER) && ($row = Database::fetch_array($res)))
+ while ($row = Database::fetch_array($res)) {
$list[] = $row;
$i++;
}
@@ -261,7 +259,7 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
* without a database name
*/
if (!$singleDbForm) { //otherwise just use the main one
- mysql_select_db($row_course['db_name']);
+ Database::select_db($row_course['db_name']);
}
foreach ($c_q_list as $query) {
@@ -270,9 +268,9 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
}
if ($only_test) {
- error_log("mysql_query(".$row_course['db_name'].",$query)", 0);
+ error_log("Database::query(".$row_course['db_name'].",$query)", 0);
} else {
- $res = mysql_query($query);
+ $res = Database::query($query);
if ($log) {
error_log("In ".$row_course['db_name'].", executed: $query", 0);
}
@@ -285,15 +283,15 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
}
$sql_ip = "SELECT * FROM ".$prefix_course."item_property WHERE tool='learnpath'";
- $res_ip = mysql_query($sql_ip);
+ $res_ip = Database::query($sql_ip);
$paths = array();
- while ($row_ip = mysql_fetch_array($res_ip)) {
+ while ($row_ip = Database::fetch_array($res_ip)) {
$paths[] = $row_ip['ref'];
}
$sql_lp = "SELECT * FROM ".$prefix_course."lp";
- $res_lp = mysql_query($sql_lp);
+ $res_lp = Database::query($sql_lp);
$tbl_tool = $prefix_course."tool";
- while ($row_lp = mysql_fetch_array($res_lp)) {
+ while ($row_lp = Database::fetch_array($res_lp)) {
$time = date("Y-m-d H:i:s", time());
$vis = 'v';
$input = stripslashes($row_lp['name']);
@@ -306,20 +304,20 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
//the path is already in item_property, check the visibility is the
//same as the homepage tool's
$res2 = Database::query($sql2);
- if (mysql_num_rows($res2) > 0) {
- $row2 = mysql_fetch_array($res2);
+ if (Database::num_rows($res2) > 0) {
+ $row2 = Database::fetch_array($res2);
$vis = $row2['visibility'];
}
$visi = array('v' => 1, 'i' => 0);
if ($visi[$vis] != $row_ip['visibility']) {
$sql_upd = "UPDATE ".$prefix_course."item_propery SET visibility=".$visi[$vis]." WHERE tool='learnpath' AND ref='".$row_lp['id']."'";
- $res_upd = mysql_query($sql_upd);
+ $res_upd = Database::query($sql_upd);
}
} else {
//the path is not in item_property, insert it
$res2 = Database::query($sql2);
- if (mysql_num_rows($res2) > 0) {
- $row2 = mysql_fetch_array($res2);
+ if (Database::num_rows($res2) > 0) {
+ $row2 = Database::fetch_array($res2);
$vis = $row2['visibility'];
}
$visi = array('v' => 1, 'i' => 0);
@@ -328,7 +326,7 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
"(tool,ref,insert_date,last_edit_date,insert_user_id,lastedit_type,lastedit_user_id,visibility)" .
"VALUES" .
"('learnpath',".$row_lp['id'].",'$time','$time',1,'learnpathAdded',1,".$visi[$vis].")";
- $res_ins = mysql_query($sql_ins);
+ $res_ins = Database::query($sql_ins);
}
}
}
diff --git a/main/install/update-db-1.8.4-1.8.5.inc.php b/main/install/update-db-1.8.4-1.8.5.inc.php
index 752b184321..22952795d5 100755
--- a/main/install/update-db-1.8.4-1.8.5.inc.php
+++ b/main/install/update-db-1.8.4-1.8.5.inc.php
@@ -65,12 +65,13 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
if (empty ($dbScormForm) || $dbScormForm == 'mysql' || $dbScormForm == $dbPrefixForm) {
$dbScormForm = $dbPrefixForm.'scorm';
}
- $res = @mysql_connect($dbHostForm, $dbUsernameForm, $dbPassForm);
+
+ $res = @Database::connect(array('server' => $dbHostForm, 'username' => $dbUsernameForm, 'password' => $dbPassForm));
//if error on connection to the database, show error and exit
if ($res === false) {
- //$no = mysql_errno();
- //$msg = mysql_error();
+ //$no = Database::errno();
+ //$msg = Database::error();
//echo '
['.$no.'] - '.$msg.'
';
echo get_lang('DBServerDoesntWorkOrLoginPassIsWrong').'.
' .
@@ -84,13 +85,10 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
exit ();
}
- @mysql_query("set session sql_mode='';"); // Disabling special SQL modes (MySQL 5)
+ @Database::query("set session sql_mode='';"); // Disabling special SQL modes (MySQL 5)
+
+ $dblist = Database::get_databases();
- $dblistres = mysql_list_dbs();
- $dblist = array();
- while ($row = mysql_fetch_object($dblistres)) {
- $dblist[] = $row->Database;
- }
/*
-----------------------------------------------------------
Normal upgrade procedure:
@@ -131,12 +129,12 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
} elseif (!in_array($dbNameForm, $dblist)) {
error_log('Database '.$dbNameForm.' was not found, skipping', 0);
} else {
- mysql_select_db($dbNameForm);
+ Database::select_db($dbNameForm);
foreach ($m_q_list as $query) {
if ($only_test) {
- error_log("mysql_query($dbNameForm,$query)", 0);
+ error_log("Database::query($dbNameForm,$query)", 0);
} else {
- $res = mysql_query($query);
+ $res = Database::query($query);
if ($log) {
error_log("In $dbNameForm, executed: $query", 0);
}
@@ -159,12 +157,12 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
} elseif (!in_array($dbStatsForm, $dblist)) {
error_log('Database '.$dbStatsForm.' was not found, skipping', 0);
} else {
- mysql_select_db($dbStatsForm);
+ Database::select_db($dbStatsForm);
foreach ($s_q_list as $query) {
if ($only_test) {
- error_log("mysql_query($dbStatsForm,$query)", 0);
+ error_log("Database::query($dbStatsForm,$query)", 0);
} else {
- $res = mysql_query($query);
+ $res = Database::query($query);
if ($log) {
error_log("In $dbStatsForm, executed: $query", 0);
}
@@ -185,13 +183,13 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
} elseif (!in_array($dbUserForm, $dblist)) {
error_log('Database '.$dbUserForm.' was not found, skipping', 0);
} else {
- mysql_select_db($dbUserForm);
+ Database::select_db($dbUserForm);
foreach($u_q_list as $query){
if ($only_test) {
- error_log("mysql_query($dbUserForm,$query)", 0);
+ error_log("Database::query($dbUserForm,$query)", 0);
error_log("In $dbUserForm, executed: $query", 0);
} else {
- $res = mysql_query($query);
+ $res = Database::query($query);
}
}
}
@@ -227,16 +225,16 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
} elseif (!in_array($dbNameForm, $dblist)) {
error_log('Database '.$dbNameForm.' was not found, skipping', 0);
} else {
- mysql_select_db($dbNameForm);
- $res = mysql_query("SELECT code,db_name,directory,course_language FROM course WHERE target_course_code IS NULL ORDER BY code");
+ Database::select_db($dbNameForm);
+ $res = Database::query("SELECT code,db_name,directory,course_language FROM course WHERE target_course_code IS NULL ORDER BY code");
if ($res === false) { die('Error while querying the courses list in update_db-1.8.4-1.8.5.inc.php'); }
- if (mysql_num_rows($res) > 0) {
+ if (Database::num_rows($res) > 0) {
$i = 0;
$list = array();
- //while( ($i < MAX_COURSE_TRANSFER) && ($row = mysql_fetch_array($res)))
- while($row = mysql_fetch_array($res)) {
+ //while( ($i < MAX_COURSE_TRANSFER) && ($row = Database::fetch_array($res)))
+ while($row = Database::fetch_array($res)) {
$list[] = $row;
$i++;
}
@@ -247,7 +245,7 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
* without a database name
*/
if (!$singleDbForm) { //otherwise just use the main one
- mysql_select_db($row_course['db_name']);
+ Database::select_db($row_course['db_name']);
}
foreach ($c_q_list as $query) {
@@ -256,9 +254,9 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
}
if ($only_test) {
- error_log("mysql_query(".$row_course['db_name'].",$query)", 0);
+ error_log("Database::query(".$row_course['db_name'].",$query)", 0);
} else {
- $res = mysql_query($query);
+ $res = Database::query($query);
if ($log) {
error_log("In ".$row_course['db_name'].", executed: $query", 0);
}
@@ -272,17 +270,17 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
}
$mysql = "SELECT * FROM $mytable WHERE min_score != 0 AND prerequisite != ''";
- $myres = mysql_query($query);
+ $myres = Database::query($query);
- if ($myres!==false && mysql_num_rows($myres) > 0) {
- while ($myrow = mysql_fetch_array($myres)) {
+ if ($myres!==false && Database::num_rows($myres) > 0) {
+ while ($myrow = Database::fetch_array($myres)) {
if (is_numeric($myrow['prerequisite'])) {
$mysql2 = "UPDATE $mytable SET mastery_score = '".$myrow['min_score']."' WHERE id = '".$myrow['prerequisite']."'";
- $myres2 = mysql_query($mysql2);
+ $myres2 = Database::query($mysql2);
//echo $mysql2."
";
if ($myres2 !== false) {
$mysql3 = "UPDATE $mytable SET min_score = 0 WHERE id = '".$myrow['id']."'";
- $myres3 = mysql_query($mysql3);
+ $myres3 = Database::query($mysql3);
//echo $mysql3."
";
}
}
@@ -305,8 +303,8 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
$only_dir = array();
$sql_select = "SELECT filetype FROM " . $my_course_table . " WHERE filetype = 'folder'";
- $result = mysql_query($sql_select);
- $num_row = mysql_num_rows($result);
+ $result = Database::query($sql_select);
+ $num_row = Database::num_rows($result);
// check if there are already folder registered
if ($num_row == 0) {
@@ -324,7 +322,7 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
filetype = 'folder',
post_group_id = '0',
sent_date = '0000-00-00 00:00:00' ";
- mysql_query($sql_insert_all);
+ Database::query($sql_insert_all);
}
}
diff --git a/main/install/update-db-1.8.5-1.8.6.inc.php b/main/install/update-db-1.8.5-1.8.6.inc.php
index 445ffdbc36..89aee52239 100755
--- a/main/install/update-db-1.8.5-1.8.6.inc.php
+++ b/main/install/update-db-1.8.5-1.8.6.inc.php
@@ -66,12 +66,13 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
if (empty ($dbScormForm) || $dbScormForm == 'mysql' || $dbScormForm == $dbPrefixForm) {
$dbScormForm = $dbPrefixForm.'scorm';
}
- $res = @mysql_connect($dbHostForm, $dbUsernameForm, $dbPassForm);
+
+ $res = @Database::connect(array('server' => $dbHostForm, 'username' => $dbUsernameForm, 'password' => $dbPassForm));
//if error on connection to the database, show error and exit
if ($res === false) {
- //$no = mysql_errno();
- //$msg = mysql_error();
+ //$no = Database::errno();
+ //$msg = Database::error();
//echo '
['.$no.'] - '.$msg.'
';
echo get_lang('DBServerDoesntWorkOrLoginPassIsWrong').'.
' .
@@ -85,13 +86,9 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
exit ();
}
- @mysql_query("set session sql_mode='';"); // Disabling special SQL modes (MySQL 5)
+ @Database::query("set session sql_mode='';"); // Disabling special SQL modes (MySQL 5)
- $dblistres = mysql_list_dbs();
- $dblist = array();
- while ($row = mysql_fetch_object($dblistres)) {
- $dblist[] = $row->Database;
- }
+ $dblist = Database::get_databases();
$perm = api_get_permissions_for_new_directories();
@@ -135,12 +132,12 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
} elseif(!in_array($dbNameForm, $dblist)) {
error_log('Database '.$dbNameForm.' was not found, skipping', 0);
} else {
- mysql_select_db($dbNameForm);
+ Database::select_db($dbNameForm);
foreach ($m_q_list as $query) {
if ($only_test) {
- error_log("mysql_query($dbNameForm,$query)", 0);
+ error_log("Database::query($dbNameForm,$query)", 0);
} else {
- $res = mysql_query($query);
+ $res = Database::query($query);
if ($log) {
error_log("In $dbNameForm, executed: $query", 0);
}
@@ -152,15 +149,15 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
// Filling the access_url_rel_user table with access_url_id by default = 1
$query = "SELECT user_id FROM $dbNameForm.user";
- $result_users = mysql_query($query);
- while ($row= mysql_fetch_array($result_users, MYSQL_NUM)) {
+ $result_users = Database::query($query);
+ while ($row = Database::fetch_array($result_users, 'NUM')) {
$user_id = $row[0];
$sql = "INSERT INTO $dbNameForm.access_url_rel_user SET user_id=$user_id, access_url_id=1";
- $res = mysql_query($sql);
+ $res = Database::query($sql);
//Updating user image
$query = "SELECT picture_uri FROM $dbNameForm.user WHERE user_id=$user_id";
- $res = mysql_query($query);
- $picture_uri = mysql_fetch_array($res, MYSQL_NUM);
+ $res = Database::query($query);
+ $picture_uri = Database::fetch_array($res, 'NUM');
$file = $picture_uri[0];
$dir = api_get_path(SYS_CODE_PATH).'upload/users/';
$image_repository = file_exists($dir.$file) ? $dir.$file : $dir.$user_id.'/'.$file;
@@ -212,10 +209,10 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
}
// Filling the access_url_rel_session table with access_url_id by default = 1
$query = "SELECT id FROM $dbNameForm.session";
- $result = mysql_query($query);
- while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
+ $result = Database::query($query);
+ while ($row = Database::fetch_array($result, 'NUM')) {
$sql = "INSERT INTO $dbNameForm.access_url_rel_session SET session_id=".$row[0].", access_url_id=1";
- $res = mysql_query($sql);
+ $res = Database::query($sql);
}
//Since the parser of the migration DB does not work for this kind of inserts (HTML) we move it here
@@ -254,7 +251,7 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {