Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

Differences Between: [Versions 310 and 311] [Versions 311 and 400] [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403] [Versions 39 and 311]

(no description)

Copyright: (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
Copyright: (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Version: v5.21.0 2021-02-27
File Size: 370 lines (10 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 2 files
 lib/adodb/adodb-errorpear.inc.php
 lib/adodb/adodb.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

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

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

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

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

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

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.

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

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

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

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

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