Note:

If you want to create a new page for developers, you should create it on the Moodle Developer Resource site.

DML drivers: Difference between revisions

From MoodleDocs
No edit summary
No edit summary
Line 1: Line 1:
{{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.
{{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 two sample native drivers - mysqli and pgsql. The benefits are:
At present there are three native drivers - mysqli, pgsql and unfinished Oracle driver. The benefits are:
* more optimised and probably faster
* more optimised and probably faster
* consume less memory
* consume less memory
Line 8: Line 8:
* and more
* and more


Please note that native drivers are now used by default in HEAD because we need to get as much testing as possible ;-)
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 (
  'dbpersit' => 0,
  //'logall'  => true,
  'logslow'  => 5,
  'logerrors'  => true,
);
 
* '''logall''' - log aal 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==
==TODO==

Revision as of 16:15, 13 June 2009

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 (
 'dbpersit' => 0,
 //'logall'   => true,
 'logslow'  => 5,
 'logerrors'  => true,
);
  • logall - log aal 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