Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

Differences Between: [Versions 310 and 400] [Versions 311 and 400] [Versions 39 and 400]

PEAR DB Emulation Layer for ADOdb. The following code is modelled on PEAR DB code by Stig Bakken <ssb@fast.no> and Tomas V.V.Cox <cox@idecnet.com>. Portions (c)1997-2002 The PHP Group.

Copyright: 2000-2013 John Lim
Copyright: 2014 Damien Regad, Mark Newnham and the ADOdb community
License: BSD-3-Clause
License: LGPL-2.1-or-later
File Size: 377 lines (10 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 2 files
 lib/adodb/adodb.inc.php
 lib/adodb/adodb-errorpear.inc.php

Defines 1 class

DB:: (7 methods):
  factory()
  connect()
  apiVersion()
  isError()
  isWarning()
  parseDSN()
  assertExtension()


Class: DB  - X-Ref

The main "DB" class is simply a container class with some static
methods for creating DB objects as well as some utility functions
common to all parts of DB.

factory($type)   X-Ref
Create a new DB object for the specified database type

return: object a newly created DB object, or a DB error code on
param: $type string database type, for example "mysql"

connect($dsn, $options = false)   X-Ref
Create a new DB object and connect to the specified database

return: object a newly created DB connection object, or a DB
param: $dsn mixed "data source name", see the DB::parseDSN
param: $options mixed if boolean (or scalar), tells whether

apiVersion()   X-Ref
Return the DB API version

return: int the DB API version number

isError($value)   X-Ref
Tell whether a result code from a DB method is an error

return: bool whether $value is an error
param: $value int result code

isWarning($value)   X-Ref
Tell whether a result code from a DB method is a warning.
Warnings differ from errors in that they are generated by DB,
and are not fatal.

return: bool whether $value is a warning
param: $value mixed result value

parseDSN($dsn)   X-Ref
Parse a data source name

author: Tomas V.V.Cox <cox@idecnet.com>
return: array an associative array with the following keys:
param: $dsn string Data Source Name to be parsed

assertExtension($name)   X-Ref
Load a PHP database extension if it is not loaded already.

return: bool true if the extension was already or successfully
param: $name the base name of the extension (without the .so or