Note:

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

DB layer 2.0: Difference between revisions

From MoodleDocs
m (Development:Datalib 2.0 moved to Development:dmllib 2.0)
mNo edit summary
 
(30 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{Template:Development:dmllib 2.0}}{{Moodle_2.0}}__NOTOC__
== Objectives ==
== Objectives ==


* Switch to prepared statements - using placeholders and preparing statements protects against sql injection
* Switch to prepared statements - using placeholders and preparing statements protects against sql injection
* Remove the need for data to be add/strip slashed all over the place in the code.
* Remove the need for data to be add/strip slashed all over the place in the code.
* Make it so that the database object can be subclassed - this means for unit tests that want to test database access, the test framework can override necessary methods
* Enable easier and productive unit tests.


== Requirements ==


== Ideas ==
* 100% cross-db
* [http://en.wikipedia.org/wiki/Object-relational_mapping Object Relational Mapping style]
* OOP implementation:
* There are already some PHP ORM tools:
** Full abstraction: Hide underlying libraries (adodb, pdo...) and drivers to Moodle developers completely.
** [http://www.phpdoctrine.org/ Doctrine]
** Make it so that the database object can be subclassed - this means for unit tests that want to test database access, the test framework can override necessary methods
** [http://www.phpobjectgenerator.com/ PHP Object Generator]
** support ? and :param parameter types (independently of the param types supported by each driver).
** [http://propel.phpdb.org/trac/ Propel]
** global $DB
** profiling, logging and exceptions
* Easy to use (consistent and similar to current dmllib 1.0)
* Easy to migrate (provide documentation and utilities to help on that)
* Complete unit testing (self)
* Easy unit testing (moodle - real and mockup)
* Well documented (PHPDocs + use examples)
* Tasks, bugs and progress tracked in MDL-14679
* Due date: June 24th 2008
 
== See also ==
 
* [[XMLDB Documentation|XMLDB Documentation]]: where both xmldb and ddl stuff is explained.
* [[DDL functions|DDL functions]] - Documentation for all the Data Definition Language (DDL) functions available inside Moodle.
* [[DML functions|DML functions]] - Documentation for all the Data Manipulation Language (DML) functions available inside Moodle.

Latest revision as of 23:32, 25 July 2008

Moodle 2.0


Objectives

  • Switch to prepared statements - using placeholders and preparing statements protects against sql injection
  • Remove the need for data to be add/strip slashed all over the place in the code.
  • Enable easier and productive unit tests.

Requirements

  • 100% cross-db
  • OOP implementation:
    • Full abstraction: Hide underlying libraries (adodb, pdo...) and drivers to Moodle developers completely.
    • Make it so that the database object can be subclassed - this means for unit tests that want to test database access, the test framework can override necessary methods
    • support ? and :param parameter types (independently of the param types supported by each driver).
    • global $DB
    • profiling, logging and exceptions
  • Easy to use (consistent and similar to current dmllib 1.0)
  • Easy to migrate (provide documentation and utilities to help on that)
  • Complete unit testing (self)
  • Easy unit testing (moodle - real and mockup)
  • Well documented (PHPDocs + use examples)
  • Tasks, bugs and progress tracked in MDL-14679
  • Due date: June 24th 2008

See also

  • XMLDB Documentation: where both xmldb and ddl stuff is explained.
  • DDL functions - Documentation for all the Data Definition Language (DDL) functions available inside Moodle.
  • DML functions - Documentation for all the Data Manipulation Language (DML) functions available inside Moodle.