-<?php // $Id$
-
-///////////////////////////////////////////////////////////////////////////
-// //
-// NOTICE OF COPYRIGHT //
-// //
-// Moodle - Modular Object-Oriented Dynamic Learning Environment //
-// http://moodle.com //
-// //
-// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
-// (C) 2001-3001 Eloy Lafuente (stronk7) http://contiento.com //
-// //
-// This program is free software; you can redistribute it and/or modify //
-// it under the terms of the GNU General Public License as published by //
-// the Free Software Foundation; either version 2 of the License, or //
-// (at your option) any later version. //
-// //
-// This program is distributed in the hope that it will be useful, //
-// but WITHOUT ANY WARRANTY; without even the implied warranty of //
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
-// GNU General Public License for more details: //
-// //
-// http://www.gnu.org/copyleft/gpl.html //
-// //
-///////////////////////////////////////////////////////////////////////////
-
-/// This class represent the base generator class where all the
-/// needed functions to generate proper SQL are defined.
-
-/// The rest of classes will inherit, by default, the same logic.
-/// Functions will be overriden as needed to generate correct SQL.
-
+<?php
+
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+
+
+/**
+ * Dtabase manager instance is responsible for all database structure
+ * modifications.
+ *
+ * @package moodlecore
+ * @subpackage DDL
+ * @copyright 1999 onwards Martin Dougiamas http://dougiamas.com
+ * 2001-3001 Eloy Lafuente (stronk7) http://contiento.com
+ * 2008 Petr Skoda http://skodak.org
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+/**
+ * Dtabase manager instance is responsible for all database structure
+ * modifications. It is using db specific generators to find out
+ * the correct SQL syntax to do that.
+ */
class database_manager {
protected $mdb;
-<?php // $Id$
-
-///////////////////////////////////////////////////////////////////////////
-// //
-// NOTICE OF COPYRIGHT //
-// //
-// Moodle - Modular Object-Oriented Dynamic Learning Environment //
-// http://moodle.com //
-// //
-// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
-// (C) 2001-3001 Eloy Lafuente (stronk7) http://contiento.com //
-// //
-// This program is free software; you can redistribute it and/or modify //
-// it under the terms of the GNU General Public License as published by //
-// the Free Software Foundation; either version 2 of the License, or //
-// (at your option) any later version. //
-// //
-// This program is distributed in the hope that it will be useful, //
-// but WITHOUT ANY WARRANTY; without even the implied warranty of //
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
-// GNU General Public License for more details: //
-// //
-// http://www.gnu.org/copyleft/gpl.html //
-// //
-///////////////////////////////////////////////////////////////////////////
+<?php
+
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+
+
+/**
+ * MSSQL specific SQL code generator.
+ *
+ * @package moodlecore
+ * @subpackage DDL
+ * @copyright 1999 onwards Martin Dougiamas http://dougiamas.com
+ * 2001-3001 Eloy Lafuente (stronk7) http://contiento.com
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
require_once($CFG->libdir.'/ddl/sql_generator.php');
-<?php // $Id$
-
-///////////////////////////////////////////////////////////////////////////
-// //
-// NOTICE OF COPYRIGHT //
-// //
-// Moodle - Modular Object-Oriented Dynamic Learning Environment //
-// http://moodle.com //
-// //
-// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
-// (C) 2001-3001 Eloy Lafuente (stronk7) http://contiento.com //
-// //
-// This program is free software; you can redistribute it and/or modify //
-// it under the terms of the GNU General Public License as published by //
-// the Free Software Foundation; either version 2 of the License, or //
-// (at your option) any later version. //
-// //
-// This program is distributed in the hope that it will be useful, //
-// but WITHOUT ANY WARRANTY; without even the implied warranty of //
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
-// GNU General Public License for more details: //
-// //
-// http://www.gnu.org/copyleft/gpl.html //
-// //
-///////////////////////////////////////////////////////////////////////////
+<?php
+
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+
+
+/**
+ * Mysql specific SQL code generator.
+ *
+ * @package moodlecore
+ * @subpackage DDL
+ * @copyright 1999 onwards Martin Dougiamas http://dougiamas.com
+ * 2001-3001 Eloy Lafuente (stronk7) http://contiento.com
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
require_once($CFG->libdir.'/ddl/sql_generator.php');
-<?php // $Id$
-
-///////////////////////////////////////////////////////////////////////////
-// //
-// NOTICE OF COPYRIGHT //
-// //
-// Moodle - Modular Object-Oriented Dynamic Learning Environment //
-// http://moodle.com //
-// //
-// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
-// (C) 2001-3001 Eloy Lafuente (stronk7) http://contiento.com //
-// //
-// This program is free software; you can redistribute it and/or modify //
-// it under the terms of the GNU General Public License as published by //
-// the Free Software Foundation; either version 2 of the License, or //
-// (at your option) any later version. //
-// //
-// This program is distributed in the hope that it will be useful, //
-// but WITHOUT ANY WARRANTY; without even the implied warranty of //
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
-// GNU General Public License for more details: //
-// //
-// http://www.gnu.org/copyleft/gpl.html //
-// //
-///////////////////////////////////////////////////////////////////////////
+<?php
+
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+
+
+/**
+ * Oracle specific SQL code generator.
+ *
+ * @package moodlecore
+ * @subpackage DDL
+ * @copyright 1999 onwards Martin Dougiamas http://dougiamas.com
+ * 2001-3001 Eloy Lafuente (stronk7) http://contiento.com
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
require_once($CFG->libdir.'/ddl/sql_generator.php');
-<?php // $Id$
-
-///////////////////////////////////////////////////////////////////////////
-// //
-// NOTICE OF COPYRIGHT //
-// //
-// Moodle - Modular Object-Oriented Dynamic Learning Environment //
-// http://moodle.com //
-// //
-// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
-// (C) 2001-3001 Eloy Lafuente (stronk7) http://contiento.com //
-// //
-// This program is free software; you can redistribute it and/or modify //
-// it under the terms of the GNU General Public License as published by //
-// the Free Software Foundation; either version 2 of the License, or //
-// (at your option) any later version. //
-// //
-// This program is distributed in the hope that it will be useful, //
-// but WITHOUT ANY WARRANTY; without even the implied warranty of //
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
-// GNU General Public License for more details: //
-// //
-// http://www.gnu.org/copyleft/gpl.html //
-// //
-///////////////////////////////////////////////////////////////////////////
+<?php
+
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+
+
+/**
+ * PostgreSQL specific SQL code generator.
+ *
+ * @package moodlecore
+ * @subpackage DDL
+ * @copyright 1999 onwards Martin Dougiamas http://dougiamas.com
+ * 2001-3001 Eloy Lafuente (stronk7) http://contiento.com
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
require_once($CFG->libdir.'/ddl/sql_generator.php');
/**
* Unit tests for (some of) ddl lib.
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
- * @package moodlecore
*/
if (!defined('MOODLE_INTERNAL')) {
-<?php // $Id$
-
-///////////////////////////////////////////////////////////////////////////
-// //
-// NOTICE OF COPYRIGHT //
-// //
-// Moodle - Modular Object-Oriented Dynamic Learning Environment //
-// http://moodle.com //
-// //
-// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
-// (C) 2001-3001 Eloy Lafuente (stronk7) http://contiento.com //
-// //
-// This program is free software; you can redistribute it and/or modify //
-// it under the terms of the GNU General Public License as published by //
-// the Free Software Foundation; either version 2 of the License, or //
-// (at your option) any later version. //
-// //
-// This program is distributed in the hope that it will be useful, //
-// but WITHOUT ANY WARRANTY; without even the implied warranty of //
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
-// GNU General Public License for more details: //
-// //
-// http://www.gnu.org/copyleft/gpl.html //
-// //
-///////////////////////////////////////////////////////////////////////////
-
-/// This class represent the base generator class where all the
-/// needed functions to generate proper SQL are defined.
-
-/// The rest of classes will inherit, by default, the same logic.
-/// Functions will be overriden as needed to generate correct SQL.
-
+<?php
+
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+
+
+/**
+ * This class represent the base generator class where all the
+ * needed functions to generate proper SQL are defined.
+ *
+ * The rest of classes will inherit, by default, the same logic.
+ * Functions will be overriden as needed to generate correct SQL.
+ *
+ * @package moodlecore
+ * @subpackage DDL
+ * @copyright 1999 onwards Martin Dougiamas http://dougiamas.com
+ * 2001-3001 Eloy Lafuente (stronk7) http://contiento.com
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+/**
+ * Abstract sql generator class, base for all bd specific implementations.
+ */
abstract class sql_generator {
/// Please, avoid editing this defaults in this base class!
-<?php //$Id$
-
-///////////////////////////////////////////////////////////////////////////
-// //
-// NOTICE OF COPYRIGHT //
-// //
-// Moodle - Modular Object-Oriented Dynamic Learning Environment //
-// http://moodle.com //
-// //
-// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
-// (C) 2001-3001 Eloy Lafuente (stronk7) http://contiento.com //
-// //
-// This program is free software; you can redistribute it and/or modify //
-// it under the terms of the GNU General Public License as published by //
-// the Free Software Foundation; either version 2 of the License, or //
-// (at your option) any later version. //
-// //
-// This program is distributed in the hope that it will be useful, //
-// but WITHOUT ANY WARRANTY; without even the implied warranty of //
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
-// GNU General Public License for more details: //
-// //
-// http://www.gnu.org/copyleft/gpl.html //
-// //
-///////////////////////////////////////////////////////////////////////////
+<?php
+
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+
+
+/**
+ * Experimental SQLite specific SQL code generator.
+ *
+ * @package moodlecore
+ * @subpackage DDL
+ * @copyright 2008 Andrei Bautu
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
require_once($CFG->libdir.'/ddl/sql_generator.php');
<?php
-// This file is part of Moodle - http://moodle.org/
-//
+// This file is part of Moodle - http://moodle.org/
+//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
-//
+//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+
/**
* This library includes all the required functions used to handle the DB
* structure (DDL) independently of the underlying RDBMS in use.
*
* For further documentation, visit {@link http://docs.moodle.org/en/DDL_functions}
*
- * @package moodlecore
- * @copyright (C) 2001-3001 Eloy Lafuente (stronk7) {@link http://contiento.com}
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package moodlecore
+ * @subpackage DDL
+ * @copyright 2001-3001 Eloy Lafuente (stronk7) http://contiento.com
+ * 2008 Petr Skoda http://skodak.org
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-/** Add required library */
+// Add required library
require_once($CFG->libdir.'/xmlize.php');
-/** Add required XMLDB constants */
+// Add required XMLDB constants
require_once($CFG->libdir.'/xmldb/xmldb_constants.php');
-/** Add required XMLDB DB classes */
+// Add required XMLDB DB classes
require_once($CFG->libdir.'/xmldb/xmldb_object.php');
-/** Add required XMLDB DB classes */
+// Add required XMLDB DB classes
require_once($CFG->libdir.'/xmldb/xmldb_file.php');
-/** Add required XMLDB DB classes */
+// Add required XMLDB DB classes
require_once($CFG->libdir.'/xmldb/xmldb_structure.php');
-/** Add required XMLDB DB classes */
+// Add required XMLDB DB classes
require_once($CFG->libdir.'/xmldb/xmldb_table.php');
-/** Add required XMLDB DB classes */
+// Add required XMLDB DB classes
require_once($CFG->libdir.'/xmldb/xmldb_field.php');
-/** Add required XMLDB DB classes */
+// Add required XMLDB DB classes
require_once($CFG->libdir.'/xmldb/xmldb_key.php');
-/** Add required XMLDB DB classes */
+// Add required XMLDB DB classes
require_once($CFG->libdir.'/xmldb/xmldb_index.php');
-/** Add required XMLDB DB classes */
+// Add required XMLDB DB classes
require_once($CFG->libdir.'/xmldb/xmldb_statement.php');
require_once($CFG->libdir.'/ddl/sql_generator.php');
/**
* DDL exception class, use instead of error() and "return false;" in ddl code.
- *
- * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @package moodlecore
*/
class ddl_exception extends moodle_exception {
/**
/**
* Table does not exist problem exception
- *
- * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @package moodlecore
*/
class ddl_table_missing_exception extends ddl_exception {
/**
/**
* Table does not exist problem exception
- *
- * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @package moodlecore
*/
class ddl_field_missing_exception extends ddl_exception {
/**
/**
* Error during changing db structure
- *
- * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @package moodlecore
*/
class ddl_change_structure_exception extends ddl_exception {
/** @var string */