DML drivers

Jump to: navigation, search

Moodle 2.0

Previous versions were using adodb abstraction partially encapsulated by old DML api. The database drivers are now fully separated from the rest of code and it is even possible to create new native drivers that do not rely on adodb abstraction anymore.

At present there are three native drivers - mysqli, pgsql and unfinished Oracle driver. The benefits are:

  • more optimised and probably faster
  • consume less memory
  • better possibility to improve logging, debugging, profiling, etc.
  • less code, easier to fix and maintain
  • and more

Please note old adodb based drivers will be removed before the branching of 2.0.

Query logging

New native DML drivers support logging of database queries to database table. Logging can be enabled in config.php

$CFG->dboptions = array (
 'dbpersist' => 0,
 //'logall'   => true,
 'logslow'  => 5,
 'logerrors'  => true,
);
  • logall - log all queries - suitable only for developers, causes high server loads
  • logslow - log queries that take longer than specified number of seconds (float values are accepted)
  • logerrors - log all error queries

TODO

  • add more info here
  • add separate docs pages for each driver - describe all options there

See also

  • DML functions: Where all the functions used to handle DB data (DML) are defined.
  • DML exceptions: New DML code is throwing exceptions instead of returning false if anything goes wrong