summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Andreev <narf@bofh.bg>2012-11-06 00:11:22 +0100
committerAndrey Andreev <narf@bofh.bg>2012-11-06 00:11:22 +0100
commiteaa60c71082c1e49f8a48d633347c98b68a387c0 (patch)
tree41438b0e6fde0dcb3fd2348e5b52dc9c128f88db
parentd743cdbe448258cc7f02abf15e8dc797dc6403eb (diff)
Added possibility to pass custom database objects to DB Forge and DB Utilities
Also, their property is no longer public and the utility class no longer extends CI_DB_forge.
-rw-r--r--system/core/Loader.php61
-rw-r--r--system/database/DB_forge.php9
-rw-r--r--system/database/DB_utility.php11
-rw-r--r--system/database/drivers/mysql/mysql_forge.php5
-rw-r--r--system/database/drivers/mysqli/mysqli_forge.php5
-rw-r--r--system/database/drivers/pdo/subdrivers/pdo_mysql_forge.php5
-rw-r--r--system/database/drivers/pdo/subdrivers/pdo_pgsql_forge.php5
-rw-r--r--system/database/drivers/pdo/subdrivers/pdo_sqlite_forge.php5
-rw-r--r--system/database/drivers/postgre/postgre_forge.php5
-rw-r--r--system/database/drivers/sqlite3/sqlite3_forge.php5
-rw-r--r--user_guide_src/source/changelog.rst58
-rw-r--r--user_guide_src/source/database/forge.rst32
-rw-r--r--user_guide_src/source/database/utilities.rst78
-rw-r--r--user_guide_src/source/installation/upgrade_300.rst2
14 files changed, 165 insertions, 121 deletions
diff --git a/system/core/Loader.php b/system/core/Loader.php
index 808fa80df..9525f35d0 100644
--- a/system/core/Loader.php
+++ b/system/core/Loader.php
@@ -352,26 +352,30 @@ class CI_Loader {
/**
* Load the Database Utilities Class
*
- * @return void
+ * @param object $db Database object
+ * @param bool $return Whether to return the DB Forge class object or not
+ * @return void|object
*/
- public function dbutil()
+ public function dbutil($db = NULL, $return = FALSE)
{
- if ( ! class_exists('CI_DB'))
- {
- $this->database();
- }
-
$CI =& get_instance();
- // for backwards compatibility, load dbforge so we can extend dbutils off it
- // this use is deprecated and strongly discouraged
- $CI->load->dbforge();
+ if ( ! is_object($db) OR ! ($db instanceof CI_DB))
+ {
+ class_exists('CI_DB', FALSE) OR $this->database();
+ $db =& $CI->db;
+ }
require_once(BASEPATH.'database/DB_utility.php');
- require_once(BASEPATH.'database/drivers/'.$CI->db->dbdriver.'/'.$CI->db->dbdriver.'_utility.php');
- $class = 'CI_DB_'.$CI->db->dbdriver.'_utility';
+ require_once(BASEPATH.'database/drivers/'.$db->dbdriver.'/'.$db->dbdriver.'_utility.php');
+ $class = 'CI_DB_'.$db->dbdriver.'_utility';
+
+ if ($return === TRUE)
+ {
+ return new $class($db);
+ }
- $CI->dbutil = new $class();
+ $CI->dbutil = new $class($db);
}
// --------------------------------------------------------------------
@@ -379,35 +383,42 @@ class CI_Loader {
/**
* Load the Database Forge Class
*
- * @return void
+ * @param object $db Database object
+ * @param bool $return Whether to return the DB Forge class object or not
+ * @return void|object
*/
- public function dbforge()
+ public function dbforge($db = NULL, $return = FALSE)
{
- if ( ! class_exists('CI_DB'))
+ $CI =& get_instance();
+ if ( ! is_object($db) OR ! ($db instanceof CI_DB))
{
- $this->database();
+ class_exists('CI_DB', FALSE) OR $this->database();
+ $db =& $CI->db;
}
- $CI =& get_instance();
-
require_once(BASEPATH.'database/DB_forge.php');
- require_once(BASEPATH.'database/drivers/'.$CI->db->dbdriver.'/'.$CI->db->dbdriver.'_forge.php');
+ require_once(BASEPATH.'database/drivers/'.$db->dbdriver.'/'.$db->dbdriver.'_forge.php');
- if ( ! empty($CI->db->subdriver))
+ if ( ! empty($db->subdriver))
{
- $driver_path = BASEPATH.'database/drivers/'.$CI->db->dbdriver.'/subdrivers/'.$CI->db->dbdriver.'_'.$CI->db->subdriver.'_forge.php';
+ $driver_path = BASEPATH.'database/drivers/'.$db->dbdriver.'/subdrivers/'.$db->dbdriver.'_'.$db->subdriver.'_forge.php';
if (file_exists($driver_path))
{
require_once($driver_path);
- $class = 'CI_DB_'.$CI->db->dbdriver.'_'.$CI->db->subdriver.'_forge';
+ $class = 'CI_DB_'.$db->dbdriver.'_'.$db->subdriver.'_forge';
}
}
else
{
- $class = 'CI_DB_'.$CI->db->dbdriver.'_forge';
+ $class = 'CI_DB_'.$db->dbdriver.'_forge';
+ }
+
+ if ($return === TRUE)
+ {
+ return new $class($db);
}
- $CI->dbforge = new $class();
+ $CI->dbforge = new $class($db);
}
// --------------------------------------------------------------------
diff --git a/system/database/DB_forge.php b/system/database/DB_forge.php
index 2b9fb169a..34140c6e0 100644
--- a/system/database/DB_forge.php
+++ b/system/database/DB_forge.php
@@ -40,7 +40,7 @@ abstract class CI_DB_forge {
*
* @var object
*/
- public $db;
+ protected $db;
/**
* Fields data
@@ -150,13 +150,12 @@ abstract class CI_DB_forge {
/**
* Class constructor
*
+ * @param object &$db Database object
* @return void
*/
- public function __construct()
+ public function __construct(&$db)
{
- // Assign the main database object to $this->db
- $CI =& get_instance();
- $this->db =& $CI->db;
+ $this->db =& $db;
log_message('debug', 'Database Forge Class Initialized');
}
diff --git a/system/database/DB_utility.php b/system/database/DB_utility.php
index f7bef6a2c..a8e34c92d 100644
--- a/system/database/DB_utility.php
+++ b/system/database/DB_utility.php
@@ -33,14 +33,14 @@ defined('BASEPATH') OR exit('No direct script access allowed');
* @author EllisLab Dev Team
* @link http://codeigniter.com/user_guide/database/
*/
-abstract class CI_DB_utility extends CI_DB_forge {
+abstract class CI_DB_utility {
/**
* Database object
*
* @var object
*/
- public $db;
+ protected $db;
// --------------------------------------------------------------------
@@ -70,13 +70,12 @@ abstract class CI_DB_utility extends CI_DB_forge {
/**
* Class constructor
*
+ * @param object &$db Database object
* @return void
*/
- public function __construct()
+ public function __construct(&$db)
{
- // Assign the main database object to $this->db
- $CI =& get_instance();
- $this->db =& $CI->db;
+ $this->db =& $db;
log_message('debug', 'Database Utility Class Initialized');
}
diff --git a/system/database/drivers/mysql/mysql_forge.php b/system/database/drivers/mysql/mysql_forge.php
index ea3207760..019f6d353 100644
--- a/system/database/drivers/mysql/mysql_forge.php
+++ b/system/database/drivers/mysql/mysql_forge.php
@@ -74,11 +74,12 @@ class CI_DB_mysql_forge extends CI_DB_forge {
/**
* Class constructor
*
+ * @param object &$db Database object
* @return void
*/
- public function __construct()
+ public function __construct(&$db)
{
- parent::__construct();
+ parent::__construct($db);
$this->_create_table .= ' DEFAULT CHARSET '.$this->db->char_set.' COLLATE '.$this->db->dbcollat;
}
diff --git a/system/database/drivers/mysqli/mysqli_forge.php b/system/database/drivers/mysqli/mysqli_forge.php
index 914d6a268..088a6a09a 100644
--- a/system/database/drivers/mysqli/mysqli_forge.php
+++ b/system/database/drivers/mysqli/mysqli_forge.php
@@ -74,11 +74,12 @@ class CI_DB_mysqli_forge extends CI_DB_forge {
/**
* Class constructor
*
+ * @param object &$db Database object
* @return void
*/
- public function __construct()
+ public function __construct(&$db)
{
- parent::__construct();
+ parent::__construct($db);
$this->_create_table .= ' DEFAULT CHARSET '.$this->db->char_set.' COLLATE '.$this->db->dbcollat;
}
diff --git a/system/database/drivers/pdo/subdrivers/pdo_mysql_forge.php b/system/database/drivers/pdo/subdrivers/pdo_mysql_forge.php
index dc856ed2c..2add7d204 100644
--- a/system/database/drivers/pdo/subdrivers/pdo_mysql_forge.php
+++ b/system/database/drivers/pdo/subdrivers/pdo_mysql_forge.php
@@ -88,11 +88,12 @@ class CI_DB_pdo_mysql_forge extends CI_DB_pdo_forge {
/**
* Class constructor
*
+ * @param object &$db Database object
* @return void
*/
- public function __construct()
+ public function __construct(&$db)
{
- parent::__construct();
+ parent::__construct($db);
$this->_create_table .= ' DEFAULT CHARSET '.$this->db->char_set.' COLLATE '.$this->db->dbcollat;
}
diff --git a/system/database/drivers/pdo/subdrivers/pdo_pgsql_forge.php b/system/database/drivers/pdo/subdrivers/pdo_pgsql_forge.php
index b5235d24b..1e4d2ac59 100644
--- a/system/database/drivers/pdo/subdrivers/pdo_pgsql_forge.php
+++ b/system/database/drivers/pdo/subdrivers/pdo_pgsql_forge.php
@@ -71,11 +71,12 @@ class CI_DB_pdo_pgsql_forge extends CI_DB_pdo_forge {
/**
* Class constructor
*
+ * @param object &$db Database object
* @return void
*/
- public function __construct()
+ public function __construct(&$db)
{
- parent::__construct();
+ parent::__construct($db);
if (version_compare($this->db->version(), '9.0', '>'))
{
diff --git a/system/database/drivers/pdo/subdrivers/pdo_sqlite_forge.php b/system/database/drivers/pdo/subdrivers/pdo_sqlite_forge.php
index 414826212..2e5f12379 100644
--- a/system/database/drivers/pdo/subdrivers/pdo_sqlite_forge.php
+++ b/system/database/drivers/pdo/subdrivers/pdo_sqlite_forge.php
@@ -68,11 +68,12 @@ class CI_DB_pdo_sqlite_forge extends CI_DB_pdo_forge {
/**
* Class constructor
*
+ * @param object &$db Database object
* @return void
*/
- public function __construct()
+ public function __construct(&$db)
{
- parent::__construct();
+ parent::__construct($db);
if (version_compare($this->db->version(), '3.3', '<'))
{
diff --git a/system/database/drivers/postgre/postgre_forge.php b/system/database/drivers/postgre/postgre_forge.php
index ad26763a4..425622fac 100644
--- a/system/database/drivers/postgre/postgre_forge.php
+++ b/system/database/drivers/postgre/postgre_forge.php
@@ -64,11 +64,12 @@ class CI_DB_postgre_forge extends CI_DB_forge {
/**
* Class constructor
*
+ * @param object &$db Database object
* @return void
*/
- public function __construct()
+ public function __construct(&$db)
{
- parent::__construct();
+ parent::__construct($db);
if (version_compare($this->db->version(), '9.0', '>'))
{
diff --git a/system/database/drivers/sqlite3/sqlite3_forge.php b/system/database/drivers/sqlite3/sqlite3_forge.php
index 7ba0f7bab..e9b91e972 100644
--- a/system/database/drivers/sqlite3/sqlite3_forge.php
+++ b/system/database/drivers/sqlite3/sqlite3_forge.php
@@ -54,11 +54,12 @@ class CI_DB_sqlite3_forge extends CI_DB_forge {
/**
* Class constructor
*
+ * @param object &$db Database object
* @return void
*/
- public function __construct()
+ public function __construct(&$db)
{
- parent::__construct();
+ parent::__construct($db);
if (version_compare($this->db->version(), '3.3', '<'))
{
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index 717d7f6ba..2cd0d7978 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -89,6 +89,26 @@ Release Date: Not Released
- Database
+ - Added **dsn** configuration setting for drivers that support DSN strings (PDO, PostgreSQL, Oracle, ODBC, CUBRID).
+ - Added **schema** configuration setting (defaults to *public*) for drivers that might need it (currently used by PostgreSQL and ODBC).
+ - Added subdrivers support (currently only used by PDO).
+ - Added an optional database name parameter to ``db_select()``.
+ - Added a constructor to the ``DB_result`` class and moved all driver-specific properties and logic out of the base ``DB_driver`` class to allow better abstraction.
+ - Removed ``protect_identifiers()`` and renamed internal method ``_protect_identifiers()`` to it instead - it was just an alias.
+ - Renamed internal method ``_escape_identifiers()`` to ``escape_identifiers()``.
+ - Updated ``escape_identifiers()`` to accept an array of fields as well as strings.
+ - MySQL and MySQLi drivers now require at least MySQL version 5.1.
+ - ``db_set_charset()`` now only requires one parameter (collation was only needed due to legacy support for MySQL versions prior to 5.1).
+ - Replaced the ``_error_message()`` and ``_error_number()`` methods with ``error()``, which returns an array containing the last database error code and message.
+ - Improved ``version()`` implementation so that drivers that have a native function to get the version number don't have to be defined in the core ``DB_driver`` class.
+ - Added ``unbuffered_row()`` method for getting a row without prefetching whole result (consume less memory).
+ - Added capability for packages to hold *database.php* config files.
+ - Added MySQL client compression support.
+ - Added encrypted connections support (for *mysql*, *sqlsrv* and PDO with *sqlsrv*).
+ - Removed :doc:`Loader Class <libraries/loader>` from Database error tracing to better find the likely culprit.
+ - Added support for SQLite3 database driver.
+ - Added Interbase/Firebird database support via the *ibase* driver.
+ - Added ODBC support for ``create_database()``, ``drop_database()`` and ``drop_table()`` in :doc:`Database Forge <database/forge>`.
- :doc:`Query Builder <database/query_builder>` changes include:
- Renamed the Active Record class to Query Builder to remove confusion with the Active Record design pattern.
- Added the ability to insert objects with ``insert_batch()``.
@@ -104,13 +124,10 @@ Release Date: Not Released
- Server version checking is now done via ``mysqli::$server_info`` instead of running an SQL query.
- Added persistent connections support for PHP >= 5.3.
- Added support for ``backup()`` in :doc:`Database Utilities <database/utilities>`.
- - Added **dsn** configuration setting for drivers that support DSN strings (PDO, PostgreSQL, Oracle, ODBC, CUBRID).
- - Added **schema** configuration setting (defaults to *public*) for drivers that might need it (currently used by PostgreSQL and ODBC).
- - Improved PDO database support.
- - Added Interbase/Firebird database support via the *ibase* driver.
- - Added an optional database name parameter to ``db_select()``.
- - Replaced the ``_error_message()`` and ``_error_number()`` methods with ``error()``, which returns an array containing the last database error code and message.
- - Improved ``version()`` implementation so that drivers that have a native function to get the version number don't have to be defined in the core ``DB_driver`` class.
+ - Improved support of the PDO driver, including:
+ - Added support for ``create_database()``, ``drop_database()`` and ``drop_table()`` in :doc:`Database Forge <database/forge>`.
+ - Added support for ``list_fields()`` in :doc:`Database Results <database/results>`.
+ - Subdrivers are now isolated from each other instead of being in one large class.
- Improved support of the PostgreSQL driver, including:
- ``pg_version()`` is now used to get the database version number, when possible.
- Added ``db_set_charset()`` support.
@@ -119,13 +136,6 @@ Release Date: Not Released
- Added ``update_batch()`` support.
- Removed ``limit()`` and ``order_by()`` support for *UPDATE* and *DELETE* queries as PostgreSQL does not support those features.
- Added a work-around for dead persistent connections to be re-created after a database restart.
- - Added a constructor to the ``DB_result`` class and moved all driver-specific properties and logic out of the base ``DB_driver`` class to allow better abstraction.
- - Removed ``protect_identifiers()`` and renamed internal method ``_protect_identifiers()`` to it instead - it was just an alias.
- - Renamed internal method ``_escape_identifiers()`` to ``escape_identifiers()``.
- - Updated ``escape_identifiers()`` to accept an array of fields as well as strings.
- - MySQL and MySQLi drivers now require at least MySQL version 5.1.
- - ``db_set_charset()`` now only requires one parameter (collation was only needed due to legacy support for MySQL versions prior to 5.1).
- - Added support for SQLite3 database driver.
- Improved support of the CUBRID driver, including:
- Added DSN string support.
- Added persistent connections support.
@@ -145,17 +155,15 @@ Release Date: Not Released
- Improved support of the SQLite driver, including:
- Added support for ``replace()`` in :doc:`Query Builder <database/query_builder>`.
- Added support for ``drop_table()`` in :doc:`Database Forge <database/forge>`.
- - Added ODBC support for ``create_database()``, ``drop_database()`` and ``drop_table()`` in :doc:`Database Forge <database/forge>`.
- - Added PDO support for ``create_database()``, ``drop_database()`` and ``drop_table()`` in :doc:`Database Forge <database/forge>`.
- - Added ``unbuffered_row()`` method for getting a row without prefetching whole result (consume less memory).
- - Added PDO support for ``list_fields()`` in :doc:`Database Results <database/results>`.
- - Added capability for packages to hold *database.php* config files
- - Added subdrivers support (currently only used by PDO).
- - Added MySQL client compression support.
- - Added encrypted connections support (for *mysql*, *sqlsrv* and PDO with *sqlsrv*).
- - Removed :doc:`Loader Class <libraries/loader>` from Database error tracing to better find the likely culprit.
- - Added an optional second parameter to ``drop_table()`` in :doc:`Database Forge <database/forge>` that allows adding the IF EXISTS condition.
- - Removed the optional AFTER clause from :doc:`Database Forge <database/forge>` method ``add_column()``.
+ - :doc:`Database Forge <database/forge>` changes include:
+ - Added an optional second parameter to ``drop_table()`` that allows adding the **IF EXISTS** condition, which is no longer the default.
+ - Added support for passing a custom database object to the loader.
+ - Removed the optional AFTER clause from method ``add_column()``.
+ - Overall improved support for all of the drivers.
+ - :doc:`Database Utility <database/utilities>` chages include:
+ - Added support for passing a custom database object to the loader.
+ - Modified the class to no longer extend :doc:`Database Forge <database/forge>`, which has been a deprecated behavior for awhile.
+ - Overall improved support for all of the drivers.
- Libraries
diff --git a/user_guide_src/source/database/forge.rst b/user_guide_src/source/database/forge.rst
index 1d6b847b4..de5748b45 100644
--- a/user_guide_src/source/database/forge.rst
+++ b/user_guide_src/source/database/forge.rst
@@ -2,7 +2,7 @@
Database Forge Class
####################
-The Database Forge Class contains functions that help you manage your
+The Database Forge Class contains methods that help you manage your
database.
.. contents:: Table of Contents
@@ -18,13 +18,25 @@ Load the Forge Class as follows::
$this->load->dbforge()
-Once initialized you will access the functions using the $this->dbforge
+You can also pass another database object to the DB Forge loader, in case
+the database you want to manage isn't the default one::
+
+ $this->myforge = $this->load->dbforge($this->other_db, TRUE);
+
+In the above example, we're passing a custom database object as the first
+parameter and then tell it to return the dbforge object, instead of
+assigning it directly to ``$this->dbforge``.
+
+.. note:: Both of the parameters can be used individually, just pass an empty
+ value as the first one if you wish to skip it.
+
+Once initialized you will access the methods using the ``$this->dbforge``
object::
- $this->dbforge->some_function()
+ $this->dbforge->some_method();
$this->dbforge->create_database('db_name')
-============================================
+==========================================
Permits you to create the database specified in the first parameter.
Returns TRUE/FALSE based on success or failure::
@@ -108,13 +120,13 @@ Additionally, the following key/values can be used:
After the fields have been defined, they can be added using
-$this->dbforge->add_field($fields); followed by a call to the
-create_table() function.
+``$this->dbforge->add_field($fields);`` followed by a call to the
+``create_table()`` method.
$this->dbforge->add_field()
-----------------------------
+---------------------------
-The add fields function will accept the above array.
+The add fields method will accept the above array.
Passing strings as fields
-------------------------
@@ -221,7 +233,7 @@ Modifying Tables
$this->dbforge->add_column()
=============================
-The add_column() function is used to modify an existing table. It
+The ``add_column()`` method is used to modify an existing table. It
accepts the same field array as above, and can be used for an unlimited
number of additional fields.
@@ -246,7 +258,7 @@ Used to remove a column from a table.
$this->dbforge->modify_column()
================================
-The usage of this function is identical to add_column(), except it
+The usage of this method is identical to ``add_column()``, except it
alters an existing column rather than adding a new one. In order to
change the name you can add a "name" key into the field defining array.
diff --git a/user_guide_src/source/database/utilities.rst b/user_guide_src/source/database/utilities.rst
index 4e83929b2..06ecb2da1 100644
--- a/user_guide_src/source/database/utilities.rst
+++ b/user_guide_src/source/database/utilities.rst
@@ -2,7 +2,7 @@
Database Utility Class
######################
-The Database Utility Class contains functions that help you manage your
+The Database Utility Class contains methods that help you manage your
database.
.. contents:: Table of Contents
@@ -22,12 +22,24 @@ Load the Utility Class as follows::
$this->load->dbutil()
-Once initialized you will access the functions using the $this->dbutil
+You can also pass another database object to the DB Utility loader, in case
+the database you want to manage isn't the default one::
+
+ $this->myutil = $this->load->dbutil($this->other_db, TRUE);
+
+In the above example, we're passing a custom database object as the first
+parameter and then tell it to return the dbutil object, instead of
+assigning it directly to ``$this->dbutil``.
+
+.. note:: Both of the parameters can be used individually, just pass an empty
+ value as the first one if you wish to skip it.
+
+Once initialized you will access the methods using the ``$this->dbutil``
object::
- $this->dbutil->some_function()
+ $this->dbutil->some_method()
-$this->dbutil->list_databases()
+$this->dbutil->list_databases();
================================
Returns an array of database names::
@@ -40,7 +52,7 @@ Returns an array of database names::
}
$this->dbutil->database_exists();
-==================================
+=================================
Sometimes it's helpful to know whether a particular database exists.
Returns a boolean TRUE/FALSE. Usage example::
@@ -50,13 +62,11 @@ Returns a boolean TRUE/FALSE. Usage example::
// some code...
}
-Note: Replace *database_name* with the name of the table you are
-looking for. This function is case sensitive.
+.. note:: Replace *database_name* with the name of the table you are
+ looking for. This method is case sensitive.
$this->dbutil->optimize_table('table_name');
-==============================================
-
-.. note:: This features is only available for MySQL/MySQLi databases.
+============================================
Permits you to optimize a table using the table name specified in the
first parameter. Returns TRUE/FALSE based on success or failure::
@@ -66,12 +76,11 @@ first parameter. Returns TRUE/FALSE based on success or failure::
echo 'Success!';
}
-.. note:: Not all database platforms support table optimization.
+.. note:: Not all database platforms support table optimization. It is
+ mostly for use with MySQL.
$this->dbutil->repair_table('table_name');
-============================================
-
-.. note:: This features is only available for MySQL/MySQLi databases.
+==========================================
Permits you to repair a table using the table name specified in the
first parameter. Returns TRUE/FALSE based on success or failure::
@@ -86,8 +95,6 @@ first parameter. Returns TRUE/FALSE based on success or failure::
$this->dbutil->optimize_database();
====================================
-.. note:: This features is only available for MySQL/MySQLi databases.
-
Permits you to optimize the database your DB class is currently
connected to. Returns an array containing the DB status messages or
FALSE on failure.
@@ -101,13 +108,14 @@ FALSE on failure.
print_r($result);
}
-.. note:: Not all database platforms support table optimization.
+.. note:: Not all database platforms support table optimization. It
+ it is mostly for use with MySQL.
-$this->dbutil->csv_from_result($db_result)
-=============================================
+$this->dbutil->csv_from_result($db_result);
+===========================================
Permits you to generate a CSV file from a query result. The first
-parameter of the function must contain the result object from your
+parameter of the method must contain the result object from your
query. Example::
$this->load->dbutil();
@@ -127,12 +135,12 @@ is used as the enclosure. Example::
echo $this->dbutil->csv_from_result($query, $delimiter, $newline, $enclosure);
-.. important:: This function will NOT write the CSV file for you. It
+.. important:: This method will NOT write the CSV file for you. It
simply creates the CSV layout. If you need to write the file
use the :doc:`File Helper <../helpers/file_helper>`.
-$this->dbutil->xml_from_result($db_result)
-=============================================
+$this->dbutil->xml_from_result($db_result);
+===========================================
Permits you to generate an XML file from a query result. The first
parameter expects a query result object, the second may contain an
@@ -151,17 +159,17 @@ optional array of config parameters. Example::
echo $this->dbutil->xml_from_result($query, $config);
-.. important:: This function will NOT write the XML file for you. It
+.. important:: This method will NOT write the XML file for you. It
simply creates the XML layout. If you need to write the file
use the :doc:`File Helper <../helpers/file_helper>`.
-$this->dbutil->backup()
-=======================
+$this->dbutil->backup();
+========================
Permits you to backup your full database or individual tables. The
backup data can be compressed in either Zip or Gzip format.
-.. note:: This features is only available for MySQL and Interbase/Firebird databases.
+.. note:: This feature is only available for MySQL and Interbase/Firebird databases.
.. note:: For Interbase/Firebird databases, the backup file name is the only parameter.
@@ -196,16 +204,16 @@ Setting Backup Preferences
--------------------------
Backup preferences are set by submitting an array of values to the first
-parameter of the backup function. Example::
+parameter of the ``backup()`` method. Example::
$prefs = array(
- 'tables' => array('table1', 'table2'), // Array of tables to backup.
- 'ignore' => array(), // List of tables to omit from the backup
- 'format' => 'txt', // gzip, zip, txt
- 'filename' => 'mybackup.sql', // File name - NEEDED ONLY WITH ZIP FILES
- 'add_drop' => TRUE, // Whether to add DROP TABLE statements to backup file
- 'add_insert' => TRUE, // Whether to add INSERT data to backup file
- 'newline' => "\n" // Newline character used in backup file
+ 'tables' => array('table1', 'table2'), // Array of tables to backup.
+ 'ignore' => array(), // List of tables to omit from the backup
+ 'format' => 'txt', // gzip, zip, txt
+ 'filename' => 'mybackup.sql', // File name - NEEDED ONLY WITH ZIP FILES
+ 'add_drop' => TRUE, // Whether to add DROP TABLE statements to backup file
+ 'add_insert' => TRUE, // Whether to add INSERT data to backup file
+ 'newline' => "\n" // Newline character used in backup file
);
$this->dbutil->backup($prefs);
diff --git a/user_guide_src/source/installation/upgrade_300.rst b/user_guide_src/source/installation/upgrade_300.rst
index 4e0b952d5..c06dab793 100644
--- a/user_guide_src/source/installation/upgrade_300.rst
+++ b/user_guide_src/source/installation/upgrade_300.rst
@@ -99,7 +99,7 @@ Step 9: Update usage of Database Forge's drop_table() method
Up until now, ``drop_table()`` added an IF EXISTS clause by default or it didn't work
at all with some drivers. In CodeIgniter 3.0, the IF EXISTS condition is no longer added
-by deafault and has an optional second parameter that allows that instead and is set to
+by default and has an optional second parameter that allows that instead and is set to
FALSE by default.
If your application relies on IF EXISTS, you'll have to change its usage.