diff --git a/main/inc/lib/database.lib.php b/main/inc/lib/database.lib.php index a33302e6f9..77ba9d4063 100644 --- a/main/inc/lib/database.lib.php +++ b/main/inc/lib/database.lib.php @@ -1,4 +1,4 @@ - * @author Patrick Cool , Ghent University */ - function escape_string($string) - { + public static function escape_string($string) { if (get_magic_quotes_gpc()) { $string = stripslashes($string); @@ -701,8 +678,7 @@ class Database * @return array Array of results as returned by php * @author Yannick Warnier */ - function fetch_array($res, $option = 'BOTH') - { + public static function fetch_array ($res, $option = 'BOTH') { if ($option != 'BOTH') { if ($option == 'ASSOC') @@ -727,8 +703,7 @@ class Database * @return object Object of class StdClass or the required class, containing the query result row * @author Yannick Warnier */ - function fetch_object($res,$class=null,$params=null) - { + public static function fetch_object ($res,$class=null,$params=null) { if(!empty($class)) { if(is_array($params)) @@ -745,8 +720,7 @@ class Database * @return array Array of results as returned by php (mysql_fetch_row) * @author Yannick Warnier */ - function fetch_row($res) - { + public static function fetch_row ($res) { return mysql_fetch_row($res); } /** @@ -755,15 +729,13 @@ class Database * @return integer The number of rows contained in this result * @author Yannick Warnier **/ - function num_rows($res) - { + public static function num_rows ($res) { return mysql_num_rows($res); } - function get_course_chat_connected_table($database_name = '') - { - $database_name_with_glue = Database::fix_database_parameter($database_name); - return Database::format_glued_course_table_name($database_name_with_glue, CHAT_CONNECTED_TABLE); + public static function get_course_chat_connected_table ($database_name = '') { + $database_name_with_glue = self::fix_database_parameter($database_name); + return self::format_glued_course_table_name($database_name_with_glue, CHAT_CONNECTED_TABLE); } /** * Acts as the relative *_result() function of most DB drivers and fetches a @@ -773,8 +745,7 @@ class Database * @param string Optional field name or number * @result mixed One cell of the result, or FALSE on error */ - function result($resource,$row,$field='') - { + public static function result ($resource,$row,$field='') { if (mysql_num_rows($resource) > 0) { if(!empty($field)) { @@ -790,16 +761,14 @@ class Database * Recovers the last ID of any insert query executed over this SQL connection * @return integer Unique ID of the latest inserted row */ - function insert_id() - { + public static function insert_id () { return mysql_insert_id(); } /** * Returns the number of affected rows * @param resource Optional database resource */ - function affected_rows($r=null) - { + public static function affected_rows ($r=null) { if(isset($r)) { return mysql_affected_rows($r); @@ -810,20 +779,19 @@ class Database } } /** - * @author Arthur Portugal, Olivier Brouckaert * This function return a resource + * documentation has been added by Arthur Portugal + * @author Olivier Brouckaert; * @param string $query - SQL query * @param string $file - optional, the file path and name of the error (__FILE__) * @param string $line - optional, the line of the error (__LINE__) * @return resource - the return value of the query */ - function query($sql,$file='',$line=0) - { + public static function query ($sql,$file='',$line=0) { return api_sql_query($sql,$file,$line); } - function error() - { + public static function error () { return mysql_error(); } /** @@ -832,7 +800,7 @@ class Database * @return string Course code * @todo move this function in a gradebook-related library */ - function get_course_by_category ($category_id) { + public static function get_course_by_category ($category_id) { $tbl_grade_categories = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY); $sql = 'SELECT course_code FROM '.$tbl_grade_categories.' WHERE id='.$category_id; $res=api_sql_query($sql, __FILE__, __LINE__);