|
Moodle
2.2.1
http://www.collinsharper.com
|
Database 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.
Definition at line 38 of file database_manager.php.
| __construct | ( | $ | mdb, |
| $ | generator | ||
| ) |
Creates new database manager
| object | moodle_database instance |
Definition at line 47 of file database_manager.php.
| add_field | ( | xmldb_table $ | xmldb_table, |
| xmldb_field $ | xmldb_field | ||
| ) |
This function will add the field to the table passed as arguments
| xmldb_table | table object (just the name is mandatory) |
| xmldb_field | field object (full specs are required) |
Check the field doesn't exist
If NOT NULL and no default given (we ask the generator about the real* default that will be used) check the table is empty
Definition at line 570 of file database_manager.php.

| add_index | ( | $ | xmldb_table, |
| $ | xmldb_intex | ||
| ) |
This function will create the index in the table passed as arguments Before creating the index, the function will check it doesn't exists
| xmldb_table | table object (just the name is mandatory) |
| xmldb_index | index object (full specs are required) |
Check index doesn't exist
Definition at line 876 of file database_manager.php.

| add_key | ( | xmldb_table $ | xmldb_table, |
| xmldb_key $ | xmldb_key | ||
| ) |
This function will create the key in the table passed as arguments
| xmldb_table | table object (just the name is mandatory) |
| xmldb_key | index object (full specs are required) |
Definition at line 812 of file database_manager.php.

| change_field_default | ( | xmldb_table $ | xmldb_table, |
| xmldb_field $ | xmldb_field | ||
| ) |
This function will change the default of the field in the table passed as arguments One null value in the default field means delete the default
| xmldb_table | table object (just the name is mandatory) |
| xmldb_field | field object (full specs are required) |
Check the field exists
Check for dependencies in the DB before performing any action
Definition at line 683 of file database_manager.php.

| change_field_notnull | ( | xmldb_table $ | xmldb_table, |
| xmldb_field $ | xmldb_field | ||
| ) |
This function will change the nullability of the field in the table passed as arguments
| xmldb_table | table object (just the name is mandatory) |
| xmldb_field | field object (full specs are required) |
Just a wrapper over change_field_type. Does exactly the same processing
Definition at line 670 of file database_manager.php.

| change_field_precision | ( | xmldb_table $ | xmldb_table, |
| xmldb_field $ | xmldb_field | ||
| ) |
This function will change the precision of the field in the table passed as arguments
| xmldb_table | table object (just the name is mandatory) |
| xmldb_field | field object (full specs are required) |
Just a wrapper over change_field_type. Does exactly the same processing
Definition at line 646 of file database_manager.php.

| change_field_type | ( | xmldb_table $ | xmldb_table, |
| xmldb_field $ | xmldb_field | ||
| ) |
This function will change the type of the field in the table passed as arguments
| xmldb_table | table object (just the name is mandatory) |
| xmldb_field | field object (full specs are required) |
Check the field exists
Check for dependencies in the DB before performing any action
Definition at line 621 of file database_manager.php.


| change_field_unsigned | ( | xmldb_table $ | xmldb_table, |
| xmldb_field $ | xmldb_field | ||
| ) |
This function will change the unsigned/signed of the field in the table passed as arguments
| xmldb_table | table object (just the name is mandatory) |
| xmldb_field | field object (full specs are required) |
Just a wrapper over change_field_type. Does exactly the same processing
Definition at line 658 of file database_manager.php.

| check_constraint_exists | ( | xmldb_table $ | xmldb_table, |
| xmldb_field $ | xmldb_field | ||
| ) |
Given one xmldb_field, check if it has a check constraint in DB
TODO: Moodle 2.1 - Drop check_constraint_exists()
| xmldb_table | the table |
| xmldb_field | the field to be searched for any existing constraint |
Definition at line 263 of file database_manager.php.


| check_database_schema | ( | xmldb_structure $ | schema | ) |
Checks the database schema against a schema specified by an xmldb_structure object
| xmldb_structure | $schema | export schema describing all known tables |
Definition at line 987 of file database_manager.php.

| create_table | ( | xmldb_table $ | xmldb_table | ) |
This function will create the table passed as argument with all its fields/keys/indexes/sequences, everything based in the XMLDB object
| xmldb_table | table object (full specs are required) |
Check table doesn't exist
Definition at line 466 of file database_manager.php.

| create_temp_table | ( | xmldb_table $ | xmldb_table | ) |
This function will create the temporary table passed as argument with all its fields/keys/indexes/sequences, everything based in the XMLDB object
If table already exists ddl_exception will be thrown, please make sure the table name does not collide with existing normal table!
| xmldb_table | table object (full specs are required) |
Definition at line 488 of file database_manager.php.

| delete_tables_from_xmldb_file | ( | $ | file | ) |
This function will delete all tables found in XMLDB file from db
| $file | full path to the XML file to be used |
Show info about the error if we can find it
Definition at line 322 of file database_manager.php.

| dispose | ( | ) |
Release all resources
Definition at line 57 of file database_manager.php.


| drop_enum_from_field | ( | xmldb_table $ | xmldb_table, |
| xmldb_field $ | xmldb_field | ||
| ) |
This function will drop the existing enum of the field in the table passed as arguments
TODO: Moodle 2.1 - Drop drop_enum_from_field()
| xmldb_table | table object (just the name is mandatory) |
| xmldb_field | field object (full specs are required) |
Check the field exists
Definition at line 710 of file database_manager.php.

| drop_field | ( | xmldb_table $ | xmldb_table, |
| xmldb_field $ | xmldb_field | ||
| ) |
This function will drop the field from the table passed as arguments
| xmldb_table | table object (just the name is mandatory) |
| xmldb_field | field object (just the name is mandatory) |
Check the field exists
Check for dependencies in the DB before performing any action
Definition at line 596 of file database_manager.php.

| drop_index | ( | $ | xmldb_table, |
| $ | xmldb_intex | ||
| ) |
This function will drop the index in the table passed as arguments Before dropping the index, the function will check it exists
| xmldb_table | table object (just the name is mandatory) |
| xmldb_index | index object (full specs are required) |
Check index exists
Definition at line 903 of file database_manager.php.

| drop_key | ( | xmldb_table $ | xmldb_table, |
| xmldb_key $ | xmldb_key | ||
| ) |
This function will drop the key in the table passed as arguments
| xmldb_table | table object (just the name is mandatory) |
| xmldb_key | key object (full specs are required) |
Definition at line 832 of file database_manager.php.

| drop_table | ( | xmldb_table $ | xmldb_table | ) |
This function will drop the table passed as argument and all the associated objects (keys, indexes, constraints, sequences, triggers) will be dropped too.
| xmldb_table | table object (just the name is mandatory) |
Check table exists
Definition at line 360 of file database_manager.php.


| drop_temp_table | ( | xmldb_table $ | xmldb_table | ) |
This function will drop the temporary table passed as argument with all its fields/keys/indexes/sequences, everything based in the XMLDB object
It is recommended to drop temp table when not used anymore.
| xmldb_table | table object |
Check table doesn't exist
Definition at line 511 of file database_manager.php.

| execute_sql | ( | $ | sql | ) | [protected] |
Execute a given sql command string
| ddl_exception | if error found |
| string | $command | The sql string you wish to be executed. |
Definition at line 87 of file database_manager.php.

| execute_sql_arr | ( | array $ | sqlarr | ) | [protected] |
This function will execute an array of SQL commands.
| ddl_exception | if error found |
| array | $sqlarr | array of sql statements to execute |
Definition at line 73 of file database_manager.php.


| field_exists | ( | $ | table, |
| $ | field | ||
| ) |
Given one xmldb_field, check if it exists in DB (true/false)
| mixed | the table to be searched (string name or xmldb_table instance) |
| mixed | the field to be searched for (string name or xmldb_field instance) |
Calculate the name of the table
Check the table exists
Calculate the name of the table
Get list of fields in table
Definition at line 136 of file database_manager.php.


| find_check_constraint_name | ( | xmldb_table $ | xmldb_table, |
| xmldb_field $ | xmldb_field | ||
| ) |
Given one xmldb_field, the function returns the name of the check constraint in DB (if exists) of false if it doesn't exist. Note that XMLDB limits the number of check constraints per field to 1 "enum-like" constraint. So, if more than one is returned, only the first one will be retrieved by this function.
TODO: Moodle 2.1 - Drop find_check_constraint_name()
| xmldb_table | the table to be searched |
| xmldb_field | the field to be searched |
Check the table exists
Check the field exists
Get list of check_constraints in table/field
Get only the 1st element. Shouldn't be more than 1 under XMLDB
Arriving here, check not found
Definition at line 228 of file database_manager.php.


| find_index_name | ( | xmldb_table $ | xmldb_table, |
| xmldb_index $ | xmldb_index | ||
| ) |
Given one xmldb_index, the function returns the name of the index in DB of false if it doesn't exist
| object | $xmldb_table | table to be searched |
| object | $xmldb_index | the index to be searched |
Calculate the name of the table
Check the table exists
Extract index columns
Get list of indexes in table
Iterate over them looking for columns coincidence
Check if index matchs queried index
If no diferences, we have find the index
Arriving here, index not found
Definition at line 172 of file database_manager.php.


| find_key_name | ( | xmldb_table $ | xmldb_table, |
| xmldb_key $ | xmldb_key | ||
| ) |
This function IS NOT IMPLEMENTED. ONCE WE'LL BE USING RELATIONAL INTEGRITY IT WILL BECOME MORE USEFUL. FOR NOW, JUST CALCULATE "OFFICIAL" KEY NAMES WITHOUT ACCESSING TO DB AT ALL. Given one xmldb_key, the function returns the name of the key in DB (if exists) of false if it doesn't exist
| xmldb_table | the table to be searched |
| xmldb_key | the key to be searched |
Get list of keys in table first primaries (we aren't going to use this now, because the MetaPrimaryKeys is awful)
TODO: To implement when we advance in relational integrity
then uniques (note that Moodle, for now, shouldn't have any UNIQUE KEY for now, but unique indexes)
TODO: To implement when we advance in relational integrity (note that AdoDB hasn't any MetaXXX for this.
then foreign (note that Moodle, for now, shouldn't have any FOREIGN KEY for now, but indexes)
TODO: To implement when we advance in relational integrity (note that AdoDB has one MetaForeignKeys() but it's far from perfect.
TODO: To create the proper functions inside each generator to retrieve all the needed KEY info (name columns, reftable and refcolumns
So all we do is to return the official name of the requested key without any confirmation!) One exception, hardcoded primary constraint names
Calculate the name suffix
And simply, return the official name
Definition at line 278 of file database_manager.php.

Reads the install.xml files for Moodle core and modules and returns an array of xmldb_structure object with xmldb_table from these files.
Definition at line 959 of file database_manager.php.

| index_exists | ( | xmldb_table $ | xmldb_table, |
| xmldb_index $ | xmldb_index | ||
| ) |
Given one xmldb_index, check if it exists in DB (true/false)
| object | $xmldb_table | the table to be searched |
| object | $xmldb_index | the index to be searched for |
Definition at line 209 of file database_manager.php.


| install_from_xmldb_file | ( | $ | file | ) |
This function will load one entire XMLDB file and call install_from_xmldb_structure.
| $file | full path to the XML file to be used |
Definition at line 405 of file database_manager.php.

| install_from_xmldb_structure | ( | $ | xmldb_structure | ) |
This function will generate all the needed SQL statements, specific for each RDBMS type and, finally, it will execute all those statements against the DB.
| object | $structure | xmldb_structure object |
Definition at line 451 of file database_manager.php.


| install_one_table_from_xmldb_file | ( | $ | file, |
| $ | tablename, | ||
| $ | cachestructures = false |
||
| ) |
This function will load one entire XMLDB file and call install_from_xmldb_structure.
| $file | full path to the XML file to be used | |
| $tablename | the name of the table. | |
| bool | $cachestructures | boolean to decide if loaded xmldb structures can be safely cached useful for testunits loading the enormous main xml file hundred of times (100x) |
Definition at line 419 of file database_manager.php.

| rename_field | ( | xmldb_table $ | xmldb_table, |
| xmldb_field $ | xmldb_field, | ||
| $ | newname | ||
| ) |
This function will rename the field in the table passed as arguments Before renaming the field, the function will check it exists
| xmldb_table | table object (just the name is mandatory) |
| xmldb_field | index object (full specs are required) |
| string | new name of the field |
Check the field exists
Check we have included full field specs
Check field isn't id. Renaming over that field is not allowed
Definition at line 741 of file database_manager.php.

| rename_index | ( | $ | xmldb_table, |
| $ | xmldb_intex, | ||
| $ | newname | ||
| ) |
This function will rename the index in the table passed as arguments Before renaming the index, the function will check it exists Experimental. Shouldn't be used at all!
| xmldb_table | table object (just the name is mandatory) |
| xmldb_index | index object (full specs are required) |
| string | new name of the index |
Check newname isn't empty
Check index exists
Definition at line 932 of file database_manager.php.

| rename_key | ( | xmldb_table $ | xmldb_table, |
| xmldb_key $ | xmldb_key, | ||
| $ | newname | ||
| ) |
This function will rename the key in the table passed as arguments Experimental. Shouldn't be used at all in normal installation/upgrade!
| xmldb_table | table object (just the name is mandatory) |
| xmldb_key | key object (full specs are required) |
| string | new name of the key |
Check newname isn't empty
Definition at line 853 of file database_manager.php.

| rename_table | ( | xmldb_table $ | xmldb_table, |
| $ | newname | ||
| ) |
This function will rename the table passed as argument Before renaming the index, the function will check it exists
| xmldb_table | table object (just the name is mandatory) |
| string | new name of the index |
Check newname isn't empty
Check table already renamed
Check new table doesn't exist
Definition at line 533 of file database_manager.php.

| reset_sequence | ( | $ | table | ) |
Reset a sequence to the id field of a table.
| string | $table | name of table |
Check the table exists
Definition at line 112 of file database_manager.php.

| table_exists | ( | $ | table | ) |
Given one xmldb_table, check if it exists in DB (true/false)
| mixed | the table to be searched (string name or xmldb_table instance) |
Definition at line 100 of file database_manager.php.

Definition at line 41 of file database_manager.php.
$mdb [protected] |
Definition at line 40 of file database_manager.php.