Removing unused functions.

skala
Julio Montoya 12 years ago
parent fb48901316
commit 24e27da7cc
  1. 3
      main/inc/lib/course.lib.php
  2. 22
      main/inc/lib/database.lib.php
  3. 67
      main/inc/lib/database.mysqli.lib.php
  4. 9
      tests/main/inc/lib/database.lib.test.php

@ -1680,9 +1680,6 @@ class CourseManager {
public static function create_database_dump($course_code) {
global $_configuration;
if ($_configuration['single_database']) {
return;
}
$sql_dump = '';
$course_code = Database::escape_string($course_code);
$table_course = Database::get_main_table(TABLE_MAIN_COURSE);

@ -51,18 +51,7 @@ class Database
return isset($_configuration['main_database']) ? $_configuration['main_database'] : null;
}
/**
* Returns the name of the database where all the personal stuff of the user is stored
* @todo use main_database
*/
public static function get_user_personal_database()
{
global $_configuration;
return $_configuration['main_database'];
}
/**
/**
* Returns the name of the current course database.
* @return mixed Glued database name of false if undefined
*/
@ -199,7 +188,7 @@ class Database
*/
public static function get_statistic_table($short_table_name)
{
return self::format_table_name(self::get_statistic_database(), $short_table_name);
return self::get_main_table($short_table_name);
}
/**
@ -212,7 +201,7 @@ class Database
*/
public static function get_user_personal_table($short_table_name)
{
return self::format_table_name(self::get_user_personal_database(), $short_table_name);
return self::get_main_table($short_table_name);
}
public static function get_course_chat_connected_table($database_name = '')
@ -1123,12 +1112,7 @@ class Database
{
global $_configuration;
$glue = isset($_configuration['db_glue']) ? $_configuration['db_glue'] : null;
/*if ($_configuration['single_database']) {
$table_name = '`'.$database.'`.`'.$table.'`';
} else {*/
$table_name = '`'.$database.$glue.$table.'`';
//}
return $table_name;
}

@ -25,7 +25,7 @@ require_once 'database.constants.inc.php';
* @package chamilo.library
*/
class Database {
/* Variable use only in the installation process to log errors. See the Database::query function */
static $log_queries = false;
@ -51,23 +51,6 @@ class Database {
return $_configuration['statistics_database'];
}
/**
* Returns the name of the SCORM database.
* @deprecated
*/
public static function get_scorm_database() {
global $_configuration;
return $_configuration['scorm_database'];
}
/**
* Returns the name of the database where all the personal stuff of the user is stored
*/
public static function get_user_personal_database() {
global $_configuration;
return $_configuration['user_personal_database'];
}
/**
* Returns the name of the current course database.
* @return mixed Glued database name of false if undefined
@ -180,7 +163,7 @@ class Database {
* @param string $short_table_name, the name of the table
*/
public static function get_statistic_table($short_table_name) {
return self::format_table_name(self::get_statistic_database(), $short_table_name);
return self::get_main_table($short_table_name);
}
/**
@ -192,7 +175,7 @@ class Database {
* @param string $short_table_name, the name of the table
*/
public static function get_user_personal_table($short_table_name) {
return self::format_table_name(self::get_user_personal_database(), $short_table_name);
return self::get_main_table($short_table_name);
}
public static function get_course_chat_connected_table($database_name = '') {
@ -663,7 +646,7 @@ class Database {
*/
public static function query($query, $connection = null, $file = null, $line = null) {
global $database_connection;
$result = @$database_connection->query($query);
if ($database_connection->errno) {
$backtrace = debug_backtrace(); // Retrieving information about the caller statement.
@ -710,19 +693,19 @@ class Database {
$info .= '</pre>';
echo $info;
}
if (isset(self::$log_queries) && self::$log_queries) {
error_log("---------------- SQL error ---------------- ");
error_log($query);
error_log('error #'.self::errno($connection));
error_log('error: '.self::error($connection));
$info = 'FILE: ' .(empty($file) ? ' unknown ' : $file);
error_log($info);
$info = 'LINE: '.(empty($line) ? ' unknown ' : $line);
error_log($info);
if (empty($type)) {
if (!empty($function)) {
$info = 'FUNCTION: ' . $function;
@ -738,7 +721,7 @@ class Database {
}
error_log("---------------- end ----------------");
}
}
return $result;
}
@ -1139,20 +1122,20 @@ class Database {
$value_array = Database::escape_string($value_array);
$clean_values = $value_array;
}
if (!empty($condition) && $clean_values != '') {
if (!empty($condition) && $clean_values != '') {
$condition = str_replace('%',"'@percentage@'", $condition); //replace "%"
$condition = str_replace("'?'","%s", $condition);
$condition = str_replace("?","%s", $condition);
$condition = str_replace("@%s@","@-@", $condition);
$condition = str_replace("%s","'%s'", $condition);
$condition = str_replace("@-@","@%s@", $condition);
//Treat conditons as string
$condition = vsprintf($condition, $clean_values);
$condition = str_replace('@percentage@','%', $condition); //replace "%"
//Treat conditons as string
$condition = vsprintf($condition, $clean_values);
$condition = str_replace('@percentage@','%', $condition); //replace "%"
$where_return .= $condition;
}
}
}
if (!empty($where_return)) {
$return_value = " WHERE $where_return" ;
@ -1160,11 +1143,11 @@ class Database {
break;
case 'order':
$order_array = $condition_data;
if (!empty($order_array)) {
// 'order' => 'id desc, name desc'
$order_array = self::escape_string($order_array);
$new_order_array = explode(',', $order_array);
$new_order_array = explode(',', $order_array);
$temp_value = array();
foreach($new_order_array as $element) {
@ -1177,19 +1160,19 @@ class Database {
$order = 'DESC';
if (in_array($element[1], array('desc', 'asc'))) {
$order = $element[1];
}
$temp_value[]= $element[0].' '.$order.' ';
}
$temp_value[]= $element[0].' '.$order.' ';
} else {
//by default DESC
$temp_value[]= $element[0].' DESC ';
$temp_value[]= $element[0].' DESC ';
}
}
if (!empty($temp_value)) {
$return_value .= ' ORDER BY '.implode(', ', $temp_value);
$return_value .= ' ORDER BY '.implode(', ', $temp_value);
} else {
//$return_value .= '';
}
}
}
}
break;
case 'limit':
@ -1219,7 +1202,7 @@ class Database {
public static function delete($table_name, $where_conditions) {
$result = false;
$where_return = self::parse_where_conditions($where_conditions);
$sql = "DELETE FROM $table_name $where_return ";
$sql = "DELETE FROM $table_name $where_return ";
$result = self::query($sql);
$affected_rows = self::affected_rows();
//@todo should return affected_rows for

@ -152,7 +152,7 @@ class TestDatabase extends UnitTestCase {
$res=$this->dbase->get_course_table($short_table_name,$database_name);
$this->assertTrue(is_string($res));
}
function testGetCourseTablePrefix() {
global $_configuration;
$res=$this->dbase->get_course_table_prefix($_configuration);
@ -221,13 +221,6 @@ class TestDatabase extends UnitTestCase {
$this->assertTrue(is_array($res));
}
function testGetUserPersonalDatabase() {
global $_configuration;
$res=$this->dbase->get_user_personal_database($_configuration);
$this->assertTrue(is_string($res));
$this->assertTrue($res);
}
function testGetUserPersonalTable(){
$short_table_name='';
$res=$this->dbase-> get_user_personal_table($short_table_name);

Loading…
Cancel
Save