MDL-15247 lib/dmllib.php is now obsolete

This commit is contained in:
skodak 2008-06-15 11:35:25 +00:00
parent 535a6fa0b5
commit 3dce78e125
22 changed files with 122 additions and 129 deletions

View File

@ -195,7 +195,7 @@
mtrace('Removing expired enrolments ...', ''); // See MDL-8785
$timenow = time();
$somefound = false;
// The preferred way saves memory, dmllib.php
// The preferred way saves memory, datablib
// find courses where limited enrolment is enabled
$sql = "SELECT ra.roleid, ra.userid, ra.contextid
FROM {course} c

View File

@ -78,8 +78,8 @@ if (!empty($tests)) {
// Create the group of tests.
$test = new AutoGroupTest(false, true);
$test->addTestFile($CFG->libdir.'/dml/simpletest/testdmllib.php');
$test->addTestFile($CFG->libdir.'/ddl/simpletest/testddllib.php');
$test->addTestFile($CFG->libdir.'/dml/simpletest/testdml.php');
$test->addTestFile($CFG->libdir.'/ddl/simpletest/testddl.php');
// Make the reporter, which is what displays the results.
$reporter = new ExHtmlReporter($showpasses);

View File

@ -77,10 +77,10 @@ if (!is_null($path)) {
// Add ddl and dml tests if requested
if ($rundbtests) {
if (!strstr($path, $CFG->libdir . '/ddl')) {
$test->addTestFile($CFG->libdir . '/ddl/simpletest/testddllib.php');
$test->addTestFile($CFG->libdir . '/ddl/simpletest/testddl.php');
}
if (!strstr($path, $CFG->libdir . '/dml')) {
$test->addTestFile($CFG->libdir . '/dml/simpletest/testdmllib.php');
$test->addTestFile($CFG->libdir . '/dml/simpletest/testdml.php');
}
}

View File

@ -147,7 +147,6 @@ $COURSE->id = 0;
require_once($CFG->libdir.'/setuplib.php');
require_once($CFG->libdir.'/weblib.php');
require_once($CFG->libdir.'/dmllib.php');
require_once($CFG->libdir.'/deprecatedlib.php');
require_once($CFG->libdir.'/moodlelib.php');
require_once($CFG->libdir.'/adminlib.php');

View File

@ -11,6 +11,89 @@
* @package moodlecore
*/
/**
* Sets up global $DB moodle_database instance
* @return void
*/
function setup_DB() {
global $CFG, $DB;
if (isset($DB)) {
return;
}
if (!isset($CFG->dbuser)) {
$CFG->dbuser = '';
}
if (!isset($CFG->dbpass)) {
$CFG->dbpass = '';
}
if (!isset($CFG->dbname)) {
$CFG->dbname = '';
}
if (!isset($CFG->dbpersist)) {
$CFG->dbpersist = false;
}
if (!isset($CFG->dblibrary)) {
$CFG->dblibrary = 'adodb';
}
if (!isset($CFG->dboptions)) {
$CFG->dboptions = array();
}
if ($CFG->dblibrary == 'adodb') {
$classname = $CFG->dbtype.'_adodb_moodle_database';
require_once($CFG->libdir.'/dml/'.$classname.'.php');
$DB = new $classname();
} else {
error('Not implemented db library yet: '.$CFG->dblibrary);
}
$CFG->dbfamily = $DB->get_dbfamily(); // TODO: BC only for now
$driverstatus = $DB->driver_installed();
if ($driverstatus !== true) {
print_error('dbdriverproblem', 'error', '', $driverstatus);
}
if (debugging('', DEBUG_ALL)) {
// catch errors
ob_start();
} else {
$prevdebug = error_reporting(0);
}
if (!$DB->connect($CFG->dbhost, $CFG->dbuser, $CFG->dbpass, $CFG->dbname, $CFG->dbpersist, $CFG->prefix, $CFG->dboptions)) {
if (debugging('', DEBUG_ALL)) {
if ($dberr = ob_get_contents()) {
$dberr = '<p><em>'.$dberr.'</em></p>';
}
ob_end_clean();
} else {
$dberr = '';
}
if (empty($CFG->noemailever) and !empty($CFG->emailconnectionerrorsto)) {
@mail($CFG->emailconnectionerrorsto,
'WARNING: Database connection error: '.$CFG->wwwroot,
'Connection error: '.$CFG->wwwroot);
}
print_error('dbconnectionfailed', 'error', '', $dberr);
}
if (debugging('', DEBUG_ALL)) {
ob_end_clean();
} else {
error_reporting($prevdebug);
}
return true;
}
/// Some constants
define('LASTACCESS_UPDATE_SECS', 60); /// Number of seconds to wait before
/// updating lastaccess information in DB.
@ -1867,10 +1950,6 @@ function add_to_log($courseid, $module, $action, $url='', $info='', $cm=0, $user
/**
* Store user last access times - called when use enters a course or site
*
* Note: we use ADOdb code directly in this function to save some CPU
* cycles here and there. They are simple operations not needing any
* of the postprocessing performed by dmllib.php
*
* @param int $courseid, empty means site
* @return void
*/

View File

@ -11,7 +11,7 @@ if (!defined('MOODLE_INTERNAL')) {
require_once($CFG->libdir . '/adminlib.php');
class ddllib_test extends UnitTestCase {
class ddl_test extends UnitTestCase {
private $tables = array();
private $tdb;

View File

@ -5,7 +5,7 @@ require_once($CFG->libdir.'/dml/adodb_moodle_recordset.php');
/**
* Abstract moodle database class
* @package dmlib
* @package dml
*/
abstract class adodb_moodle_database extends moodle_database {

View File

@ -4,7 +4,7 @@ require_once($CFG->libdir.'/dml/moodle_recordset.php');
/**
* Adodb basic moodle recordset class
* @package dmlib
* @package dml
*/
class adodb_moodle_recordset extends moodle_recordset {

View File

@ -2,9 +2,26 @@
require_once($CFG->libdir.'/dml/database_column_info.php');
/// GLOBAL CONSTANTS /////////////////////////////////////////////////////////
/**
* Bitmask, indicates only :name type parameters are supported by db backend.
*/
define('SQL_PARAMS_NAMED', 1);
/**
* Bitmask, indicates only ? type parameters are supported by db backend.
*/
define('SQL_PARAMS_QM', 2);
/**
* Bitmask, indicates only $1, $2.. type parameters are supported by db backend.
*/
define('SQL_PARAMS_DOLLAR', 4);
/**
* Abstract class representing moodle database interface.
* @package dmlib
* @package dml
*/
abstract class moodle_database {

View File

@ -5,7 +5,7 @@ require_once($CFG->libdir.'/dml/adodb_moodle_database.php');
/**
* MSSQL database class using adodb backend
* @package dmlib
* @package dml
*/
class mssql_adodb_moodle_database extends adodb_moodle_database {
/**

View File

@ -6,7 +6,7 @@ require_once($CFG->libdir.'/dml/mssql_adodb_moodle_database.php');
/**
* MSSQL_N database class using adodb backend
* @package dmlib
* @package dml
*/
class mssql_n_adodb_moodle_database extends mssql_adodb_moodle_database {

View File

@ -6,7 +6,7 @@ require_once($CFG->libdir.'/dml/mysqli_adodb_moodle_database.php');
/**
* Legacy MySQL database class using adodb backend
* @package dmlib
* @package dml
*/
class mysql_adodb_moodle_database extends mysqli_adodb_moodle_database {

View File

@ -5,7 +5,7 @@ require_once($CFG->libdir.'/dml/adodb_moodle_database.php');
/**
* Recommended MySQL database class using adodb backend
* @package dmlib
* @package dml
*/
class mysqli_adodb_moodle_database extends adodb_moodle_database {

View File

@ -6,7 +6,7 @@ require_once($CFG->libdir.'/dml/oci8po_adodb_moodle_recordset.php');
/**
* Oracle database class using adodb backend
* @package dmlib
* @package dml
*/
class oci8po_adodb_moodle_database extends adodb_moodle_database {

View File

@ -4,7 +4,7 @@ require_once($CFG->libdir.'/dml/adodb_moodle_recordset.php');
/**
* Oracle moodle recordest with special hacks
* @package dmlib
* @package dml
*/
class oci8po_adodb_moodle_recordset extends adodb_moodle_recordset {

View File

@ -6,7 +6,7 @@ require_once($CFG->libdir.'/dml/mssql_adodb_moodle_database.php');
/**
* Experimenta mssql odbc database class using adodb backend
* @package dmlib
* @package dml
*/
class odbc_mssql_adodb_moodle_database extends mssql_adodb_moodle_database {

View File

@ -5,7 +5,7 @@ require_once($CFG->libdir.'/dml/pdo_moodle_recordset.php');
/**
* Experimental pdo database class
* @package dmlib
* @package dml
*/
abstract class pdo_moodle_database extends moodle_database {

View File

@ -4,7 +4,7 @@ require_once($CFG->libdir.'/dml/moodle_recordset.php');
/**
* Experimental pdo recordset
* @package dmlib
* @package dml
*/
class pdo_moodle_recordset extends moodle_recordset {

View File

@ -5,7 +5,7 @@ require_once($CFG->libdir.'/dml/adodb_moodle_database.php');
/**
* Postgresql database class using adodb backend
* @package dmlib
* @package dml
*/
class postgres7_adodb_moodle_database extends adodb_moodle_database {

View File

@ -1,14 +1,14 @@
<?php
/**
* Unit tests for dmllib
* @package dmllib
* Unit tests for dml
* @package dml
*/
if (!defined('MOODLE_INTERNAL')) {
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
}
class dmllib_test extends UnitTestCase {
class dml_test extends UnitTestCase {
private $tables = array();
private $tdb;

View File

@ -35,104 +35,3 @@
/// http://docs.moodle.org/en/DML_functions
/// (feel free to modify, improve and document such page, thanks!)
/// GLOBAL CONSTANTS /////////////////////////////////////////////////////////
/**
* Bitmask, indicates only :name type parameters are supported by db backend.
*/
define('SQL_PARAMS_NAMED', 1);
/**
* Bitmask, indicates only ? type parameters are supported by db backend.
*/
define('SQL_PARAMS_QM', 2);
/**
* Bitmask, indicates only $1, $2.. type parameters are supported by db backend.
*/
define('SQL_PARAMS_DOLLAR', 4);
/**
* Sets up global $DB moodle_database instance
* @return void
*/
function setup_DB() {
global $CFG, $DB;
if (isset($DB)) {
return;
}
if (!isset($CFG->dbuser)) {
$CFG->dbuser = '';
}
if (!isset($CFG->dbpass)) {
$CFG->dbpass = '';
}
if (!isset($CFG->dbname)) {
$CFG->dbname = '';
}
if (!isset($CFG->dbpersist)) {
$CFG->dbpersist = false;
}
if (!isset($CFG->dblibrary)) {
$CFG->dblibrary = 'adodb';
}
if (!isset($CFG->dboptions)) {
$CFG->dboptions = array();
}
if ($CFG->dblibrary == 'adodb') {
$classname = $CFG->dbtype.'_adodb_moodle_database';
require_once($CFG->libdir.'/dml/'.$classname.'.php');
$DB = new $classname();
} else {
error('Not implemented db library yet: '.$CFG->dblibrary);
}
$CFG->dbfamily = $DB->get_dbfamily(); // TODO: BC only for now
$driverstatus = $DB->driver_installed();
if ($driverstatus !== true) {
print_error('dbdriverproblem', 'error', '', $driverstatus);
}
if (debugging('', DEBUG_ALL)) {
// catch errors
ob_start();
} else {
$prevdebug = error_reporting(0);
}
if (!$DB->connect($CFG->dbhost, $CFG->dbuser, $CFG->dbpass, $CFG->dbname, $CFG->dbpersist, $CFG->prefix, $CFG->dboptions)) {
if (debugging('', DEBUG_ALL)) {
if ($dberr = ob_get_contents()) {
$dberr = '<p><em>'.$dberr.'</em></p>';
}
ob_end_clean();
} else {
$dberr = '';
}
if (empty($CFG->noemailever) and !empty($CFG->emailconnectionerrorsto)) {
@mail($CFG->emailconnectionerrorsto,
'WARNING: Database connection error: '.$CFG->wwwroot,
'Connection error: '.$CFG->wwwroot);
}
print_error('dbconnectionfailed', 'error', '', $dberr);
}
if (debugging('', DEBUG_ALL)) {
ob_end_clean();
} else {
error_reporting($prevdebug);
}
return true;
}

View File

@ -127,7 +127,6 @@ global $HTTPSPAGEREQUIRED;
/// Load up standard libraries
require_once($CFG->libdir .'/textlib.class.php'); // Functions to handle multibyte strings
require_once($CFG->libdir .'/weblib.php'); // Functions for producing HTML
require_once($CFG->libdir .'/dmllib.php'); // Functions to handle DB data (DML)
require_once($CFG->libdir .'/datalib.php'); // Legacy lib with a big-mix of functions.
require_once($CFG->libdir .'/accesslib.php'); // Access control functions
require_once($CFG->libdir .'/deprecatedlib.php'); // Deprecated functions included for backward compatibility