summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--system/application/config/database.php97
-rw-r--r--system/database/DB.php24
-rw-r--r--system/database/DB_active_rec.php321
-rw-r--r--system/database/DB_cache.php12
-rw-r--r--system/database/DB_driver.php186
-rw-r--r--system/database/DB_forge.php323
-rw-r--r--system/database/DB_result.php50
-rw-r--r--system/database/DB_utility.php79
-rw-r--r--system/database/drivers/mssql/mssql_driver.php98
-rw-r--r--system/database/drivers/mssql/mssql_forge.php219
-rw-r--r--system/database/drivers/mssql/mssql_utility.php77
-rw-r--r--system/database/drivers/mysql/mysql_driver.php127
-rw-r--r--system/database/drivers/mysql/mysql_forge.php223
-rw-r--r--system/database/drivers/mysql/mysql_utility.php79
-rw-r--r--system/database/drivers/mysqli/mysqli_driver.php121
-rw-r--r--system/database/drivers/mysqli/mysqli_forge.php217
-rw-r--r--system/database/drivers/mysqli/mysqli_utility.php77
-rw-r--r--system/database/drivers/oci8/oci8_driver.php148
-rw-r--r--system/database/drivers/oci8/oci8_forge.php216
-rw-r--r--system/database/drivers/oci8/oci8_utility.php77
-rw-r--r--system/database/drivers/odbc/odbc_driver.php137
-rw-r--r--system/database/drivers/odbc/odbc_forge.php236
-rw-r--r--system/database/drivers/odbc/odbc_result.php2
-rw-r--r--system/database/drivers/odbc/odbc_utility.php101
-rw-r--r--system/database/drivers/postgre/postgre_driver.php129
-rw-r--r--system/database/drivers/postgre/postgre_forge.php219
-rw-r--r--system/database/drivers/postgre/postgre_utility.php77
-rw-r--r--system/database/drivers/sqlite/sqlite_driver.php129
-rw-r--r--system/database/drivers/sqlite/sqlite_forge.php233
-rw-r--r--system/database/drivers/sqlite/sqlite_result.php9
-rw-r--r--system/database/drivers/sqlite/sqlite_utility.php103
-rw-r--r--system/helpers/form_helper.php2
-rw-r--r--system/language/english/db_lang.php8
-rw-r--r--system/language/english/email_lang.php40
-rw-r--r--system/libraries/Loader.php31
-rw-r--r--user_guide/changelog.html63
-rw-r--r--user_guide/database/active_record.html109
-rw-r--r--user_guide/database/caching.html2
-rw-r--r--user_guide/database/call_function.html2
-rw-r--r--user_guide/database/configuration.html2
-rw-r--r--user_guide/database/connecting.html2
-rw-r--r--user_guide/database/examples.html2
-rw-r--r--user_guide/database/fields.html2
-rw-r--r--user_guide/database/forge.html221
-rw-r--r--user_guide/database/helpers.html2
-rw-r--r--user_guide/database/index.html5
-rw-r--r--user_guide/database/queries.html6
-rw-r--r--user_guide/database/results.html2
-rw-r--r--user_guide/database/table_data.html114
-rw-r--r--user_guide/database/transactions.html2
-rw-r--r--user_guide/database/utilities.html62
-rw-r--r--user_guide/general/alternative_php.html2
-rw-r--r--user_guide/general/ancillary_classes.html2
-rw-r--r--user_guide/general/autoloader.html2
-rw-r--r--user_guide/general/caching.html116
-rw-r--r--user_guide/general/controllers.html2
-rw-r--r--user_guide/general/core_classes.html2
-rw-r--r--user_guide/general/creating_libraries.html2
-rw-r--r--user_guide/general/credits.html2
-rw-r--r--user_guide/general/errors.html2
-rw-r--r--user_guide/general/helpers.html2
-rw-r--r--user_guide/general/hooks.html2
-rw-r--r--user_guide/general/index.html2
-rw-r--r--user_guide/general/libraries.html2
-rw-r--r--user_guide/general/managing_apps.html2
-rw-r--r--user_guide/general/models.html2
-rw-r--r--user_guide/general/plugins.html2
-rw-r--r--user_guide/general/profiling.html2
-rw-r--r--user_guide/general/quick_reference.html2
-rw-r--r--user_guide/general/requirements.html2
-rw-r--r--user_guide/general/routing.html2
-rw-r--r--user_guide/general/scaffolding.html2
-rw-r--r--user_guide/general/security.html2
-rw-r--r--user_guide/general/urls.html2
-rw-r--r--user_guide/general/views.html2
-rw-r--r--user_guide/helpers/array_helper.html2
-rw-r--r--user_guide/helpers/cookie_helper.html2
-rw-r--r--user_guide/helpers/date_helper.html2
-rw-r--r--user_guide/helpers/directory_helper.html2
-rw-r--r--user_guide/helpers/download_helper.html2
-rw-r--r--user_guide/helpers/file_helper.html2
-rw-r--r--user_guide/helpers/form_helper.html2
-rw-r--r--user_guide/helpers/html_helper.html2
-rw-r--r--user_guide/helpers/index.html2
-rw-r--r--user_guide/helpers/inflector_helper.html2
-rw-r--r--user_guide/helpers/security_helper.html2
-rw-r--r--user_guide/helpers/smiley_helper.html205
-rw-r--r--user_guide/helpers/string_helper.html177
-rw-r--r--user_guide/helpers/text_helper.html2
-rw-r--r--user_guide/helpers/typography_helper.html2
-rw-r--r--user_guide/helpers/url_helper.html2
-rw-r--r--user_guide/helpers/xml_helper.html2
-rw-r--r--user_guide/index.html2
-rw-r--r--user_guide/installation/downloads.html2
-rw-r--r--user_guide/installation/index.html2
-rw-r--r--user_guide/installation/troubleshooting.html2
-rw-r--r--user_guide/installation/upgrade_120.html2
-rw-r--r--user_guide/installation/upgrade_130.html2
-rw-r--r--user_guide/installation/upgrade_131.html2
-rw-r--r--user_guide/installation/upgrade_132.html2
-rw-r--r--user_guide/installation/upgrade_133.html2
-rw-r--r--user_guide/installation/upgrade_140.html2
-rw-r--r--user_guide/installation/upgrade_141.html2
-rw-r--r--user_guide/installation/upgrade_150.html2
-rw-r--r--user_guide/installation/upgrade_152.html2
-rw-r--r--user_guide/installation/upgrade_153.html2
-rw-r--r--user_guide/installation/upgrade_154.html2
-rw-r--r--user_guide/installation/upgrade_160.html108
-rw-r--r--user_guide/installation/upgrade_b11.html2
-rw-r--r--user_guide/installation/upgrading.html2
-rw-r--r--user_guide/libraries/benchmark.html2
-rw-r--r--user_guide/libraries/calendar.html2
-rw-r--r--user_guide/libraries/config.html2
-rw-r--r--user_guide/libraries/email.html300
-rw-r--r--user_guide/libraries/encryption.html2
-rw-r--r--user_guide/libraries/file_uploading.html2
-rw-r--r--user_guide/libraries/ftp.html2
-rw-r--r--user_guide/libraries/image_lib.html2
-rw-r--r--user_guide/libraries/input.html2
-rw-r--r--user_guide/libraries/language.html2
-rw-r--r--user_guide/libraries/loader.html2
-rw-r--r--user_guide/libraries/output.html2
-rw-r--r--user_guide/libraries/pagination.html2
-rw-r--r--user_guide/libraries/parser.html2
-rw-r--r--user_guide/libraries/table.html293
-rw-r--r--user_guide/libraries/trackback.html2
-rw-r--r--user_guide/libraries/unit_testing.html2
-rw-r--r--user_guide/libraries/uri.html253
-rw-r--r--user_guide/libraries/user_agent.html202
-rw-r--r--user_guide/libraries/validation.html2
-rw-r--r--user_guide/libraries/xmlrpc.html488
-rw-r--r--user_guide/libraries/zip.html2
-rw-r--r--user_guide/license.html2
-rw-r--r--user_guide/overview/appflow.html2
-rw-r--r--user_guide/overview/at_a_glance.html173
-rw-r--r--user_guide/overview/features.html2
-rw-r--r--user_guide/overview/goals.html2
-rw-r--r--user_guide/overview/index.html2
-rw-r--r--user_guide/overview/mvc.html2
-rw-r--r--user_guide/toc.html2
140 files changed, 6441 insertions, 857 deletions
diff --git a/system/application/config/database.php b/system/application/config/database.php
index 5293a5a6a..1ee0c4bb4 100644
--- a/system/application/config/database.php
+++ b/system/application/config/database.php
@@ -1,49 +1,50 @@
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
-/*
-| -------------------------------------------------------------------
-| DATABASE CONNECTIVITY SETTINGS
-| -------------------------------------------------------------------
-| This file will contain the settings needed to access your database.
-|
-| For complete instructions please consult the "Database Connection"
-| page of the User Guide.
-|
-| -------------------------------------------------------------------
-| EXPLANATION OF VARIABLES
-| -------------------------------------------------------------------
-|
-| ['hostname'] The hostname of your database server.
-| ['username'] The username used to connect to the database
-| ['password'] The password used to connect to the database
-| ['database'] The name of the database you want to connect to
-| ['dbdriver'] The database type. ie: mysql. Currently supported:
- mysql, mysqli, postgre, odbc, mssql
-| ['dbprefix'] You can add an optional prefix, which will be added
-| to the table name when using the Active Record class
-| ['pconnect'] TRUE/FALSE - Whether to use a persistent connection
-| ['db_debug'] TRUE/FALSE - Whether database errors should be displayed.
-| ['active_r'] TRUE/FALSE - Whether to load the active record class
-| ['cache_on'] TRUE/FALSE - Enables/disables query caching
-| ['cachedir'] The path to the folder where cache files should be stored
-|
-| The $active_group variable lets you choose which connection group to
-| make active. By default there is only one group (the "default" group).
-|
-*/
-
-$active_group = "default";
-
-$db['default']['hostname'] = "localhost";
-$db['default']['username'] = "root";
-$db['default']['password'] = "";
-$db['default']['database'] = "test";
-$db['default']['dbdriver'] = "mysql";
-$db['default']['dbprefix'] = "";
-$db['default']['active_r'] = TRUE;
-$db['default']['pconnect'] = TRUE;
-$db['default']['db_debug'] = TRUE;
-$db['default']['cache_on'] = FALSE;
-$db['default']['cachedir'] = "";
-
-
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/*
+| -------------------------------------------------------------------
+| DATABASE CONNECTIVITY SETTINGS
+| -------------------------------------------------------------------
+| This file will contain the settings needed to access your database.
+|
+| For complete instructions please consult the "Database Connection"
+| page of the User Guide.
+|
+| -------------------------------------------------------------------
+| EXPLANATION OF VARIABLES
+| -------------------------------------------------------------------
+|
+| ['hostname'] The hostname of your database server.
+| ['username'] The username used to connect to the database
+| ['password'] The password used to connect to the database
+| ['database'] The name of the database you want to connect to
+| ['dbdriver'] The database type. ie: mysql. Currently supported:
+ mysql, mysqli, postgre, odbc, mssql
+| ['dbprefix'] You can add an optional prefix, which will be added
+| to the table name when using the Active Record class
+| ['pconnect'] TRUE/FALSE - Whether to use a persistent connection
+| ['db_debug'] TRUE/FALSE - Whether database errors should be displayed.
+| ['active_r'] TRUE/FALSE - Whether to load the active record class
+| ['cache_on'] TRUE/FALSE - Enables/disables query caching
+| ['cachedir'] The path to the folder where cache files should be stored
+|
+| The $active_group variable lets you choose which connection group to
+| make active. By default there is only one group (the "default" group).
+|
+*/
+
+$active_group = "default";
+
+$db['default']['hostname'] = "localhost";
+$db['default']['username'] = "";
+$db['default']['password'] = "";
+$db['default']['database'] = "";
+$db['default']['dbdriver'] = "mysql";
+$db['default']['dbprefix'] = "";
+$db['default']['active_r'] = TRUE;
+$db['default']['pconnect'] = TRUE;
+$db['default']['db_debug'] = TRUE;
+$db['default']['cache_on'] = FALSE;
+$db['default']['cachedir'] = "";
+$db['default']['char_set'] = "utf8";
+$db['default']['dbcollat'] = "utf8_general_ci";
+
?> \ No newline at end of file
diff --git a/system/database/DB.php b/system/database/DB.php
index 9055a22c4..425c8077b 100644
--- a/system/database/DB.php
+++ b/system/database/DB.php
@@ -29,14 +29,22 @@ function &DB($params = '', $active_record = FALSE)
{
include(APPPATH.'config/database'.EXT);
- $group = ($params == '') ? $active_group : $params;
+ if ( ! isset($db) OR count($db) == 0)
+ {
+ show_error('No database connection settings were found in the database config file.');
+ }
+
+ if ($params != '')
+ {
+ $active_group = $params;
+ }
- if ( ! isset($db[$group]))
+ if ( ! isset($active_group) OR ! isset($db[$active_group]))
{
- show_error('You have specified an invalid database connection group: '.$group);
+ show_error('You have specified an invalid database connection group.');
}
- $params = $db[$group];
+ $params = $db[$active_group];
}
// No DB specified yet? Beat them senseless...
@@ -78,7 +86,13 @@ function &DB($params = '', $active_record = FALSE)
// Instantiate the DB adapter
$driver = 'CI_DB_'.$params['dbdriver'].'_driver';
- $DB =& new $driver($params);
+ $DB =& new $driver($params);
+
+ if ($DB->autoinit == TRUE)
+ {
+ $DB->initialize();
+ }
+
return $DB;
}
diff --git a/system/database/DB_active_rec.php b/system/database/DB_active_rec.php
index e697cac77..3cc65aff4 100644
--- a/system/database/DB_active_rec.php
+++ b/system/database/DB_active_rec.php
@@ -44,7 +44,6 @@ class CI_DB_active_record extends CI_DB_driver {
var $ar_wherein = array();
var $ar_aliased_tables = array();
-
/**
* Select
*
@@ -54,7 +53,7 @@ class CI_DB_active_record extends CI_DB_driver {
* @param string
* @return object
*/
- function select($select = '*')
+ function select($select = '*', $protect_identifiers = TRUE)
{
if (is_string($select))
{
@@ -64,16 +63,137 @@ class CI_DB_active_record extends CI_DB_driver {
foreach ($select as $val)
{
$val = trim($val);
+
+ if ($val != '*' && $protect_identifiers !== FALSE)
+ {
+ $val = $this->_protect_identifiers($val);
+ }
if ($val != '')
+ {
$this->ar_select[] = $val;
+ }
}
return $this;
}
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Select Max
+ *
+ * Generates a SELECT MAX(field) portion of a query
+ *
+ * @access public
+ * @param string the field
+ * @param string an alias
+ * @return object
+ */
+ function select_max($select = '', $alias='')
+ {
+ if (!is_string($select) || $select == '')
+ {
+ $this->display_error('db_invalid_query');
+ }
+
+ $alias = ($alias != '') ? $alias : $select;
+
+ $sql = 'MAX('.$this->_protect_identifiers(trim($select)).') AS '.$this->_protect_identifiers(trim($alias));
+
+ $this->ar_select[] = $sql;
+
+ return $this;
+
+ return $this;
+ }
// --------------------------------------------------------------------
/**
+ * Select Min
+ *
+ * Generates a SELECT MIN(field) portion of a query
+ *
+ * @access public
+ * @param string the field
+ * @param string an alias
+ * @return object
+ */
+ function select_min($select = '', $alias='')
+ {
+ if (!is_string($select) || $select == '')
+ {
+ $this->display_error('db_invalid_query');
+ }
+
+ $alias = ($alias != '') ? $alias : $select;
+
+ $sql = 'MIN('.$this->_protect_identifiers(trim($select)).') AS '.$this->_protect_identifiers(trim($alias));
+
+ $this->ar_select[] = $sql;
+
+ return $this;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Select Average
+ *
+ * Generates a SELECT AVG(field) portion of a query
+ *
+ * @access public
+ * @param string the field
+ * @param string an alias
+ * @return object
+ */
+ function select_avg($select = '', $alias='')
+ {
+ if (!is_string($select) || $select == '')
+ {
+ $this->display_error('db_invalid_query');
+ }
+
+ $alias = ($alias != '') ? $alias : $select;
+
+ $sql = 'AVG('.$this->_protect_identifiers(trim($select)).') AS '.$this->_protect_identifiers(trim($alias));
+
+ $this->ar_select[] = $sql;
+
+ return $this;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Select Sum
+ *
+ * Generates a SELECT SUM(field) portion of a query
+ *
+ * @access public
+ * @param string the field
+ * @param string an alias
+ * @return object
+ */
+ function select_sum($select = '', $alias='')
+ {
+ if (!is_string($select) || $select == '')
+ {
+ $this->display_error('db_invalid_query');
+ }
+
+ $alias = ($alias != '') ? $alias : $select;
+
+ $sql = 'SUM('.$this->_protect_identifiers(trim($select)).') AS '.$this->_protect_identifiers(trim($alias));
+
+ $this->ar_select[] = $sql;
+
+ return $this;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
* DISTINCT
*
* Sets a flag which tells the query string compiler to add DISTINCT
@@ -103,8 +223,7 @@ class CI_DB_active_record extends CI_DB_driver {
{
foreach ((array)$from as $val)
{
- $this->_track_aliases($val);
- $this->ar_from[] = $this->dbprefix.$val;
+ $this->ar_from[] = $this->_protect_identifiers($this->_track_aliases($val));
}
return $this;
@@ -142,17 +261,16 @@ class CI_DB_active_record extends CI_DB_driver {
// If a DB prefix is used we might need to add it to the column names
if ($this->dbprefix)
{
+ $this->_track_aliases($table);
+
// First we remove any existing prefixes in the condition to avoid duplicates
$cond = preg_replace('|('.$this->dbprefix.')([\w\.]+)([\W\s]+)|', "$2$3", $cond);
// Next we add the prefixes to the condition
$cond = preg_replace('|([\w\.]+)([\W\s]+)(.+)|', $this->dbprefix . "$1$2" . $this->dbprefix . "$3", $cond);
-
- $this->_track_aliases($table);
-
}
- $this->ar_join[] = $type.'JOIN '.$this->dbprefix.$table.' ON '.$cond;
+ $this->ar_join[] = $type.'JOIN '.$this->_protect_identifiers($this->dbprefix.$table, TRUE).' ON '.$cond;
return $this;
}
@@ -169,9 +287,9 @@ class CI_DB_active_record extends CI_DB_driver {
* @param mixed
* @return object
*/
- function where($key, $value = NULL)
+ function where($key, $value = NULL, $escape = TRUE)
{
- return $this->_where($key, $value, 'AND ');
+ return $this->_where($key, $value, 'AND ', $escape);
}
// --------------------------------------------------------------------
@@ -187,9 +305,9 @@ class CI_DB_active_record extends CI_DB_driver {
* @param mixed
* @return object
*/
- function or_where($key, $value = NULL)
+ function or_where($key, $value = NULL, $escape = TRUE)
{
- return $this->_where($key, $value, 'OR ');
+ return $this->_where($key, $value, 'OR ', $escape);
}
// --------------------------------------------------------------------
@@ -199,9 +317,9 @@ class CI_DB_active_record extends CI_DB_driver {
* this function is here for backwards compatibility, as
* orwhere() has been deprecated
*/
- function orwhere($key, $value = NULL)
+ function orwhere($key, $value = NULL, $escape = TRUE)
{
- return $this->or_where($key, $value);
+ return $this->or_where($key, $value, $escape);
}
// --------------------------------------------------------------------
@@ -217,7 +335,7 @@ class CI_DB_active_record extends CI_DB_driver {
* @param string
* @return object
*/
- function _where($key, $value = NULL, $type = 'AND ')
+ function _where($key, $value = NULL, $type = 'AND ', $escape = TRUE)
{
if ( ! is_array($key))
{
@@ -226,10 +344,9 @@ class CI_DB_active_record extends CI_DB_driver {
foreach ($key as $k => $v)
{
-
$prefix = (count($this->ar_where) == 0) ? '' : $type;
- if (is_null($key[$k]))
+ if ( ! $this->_has_operator($k) && is_null($key[$k]))
{
// value appears not to have been set, assign the test to IS NULL
$k .= ' IS NULL';
@@ -237,12 +354,25 @@ class CI_DB_active_record extends CI_DB_driver {
if ( ! is_null($v))
{
-
+
+ if ($escape === TRUE)
+ {
+ // exception for "field<=" keys
+ if ($this->_has_operator($k))
+ {
+ $k = preg_replace("/([A-Za-z_0-9]+)/", $this->_protect_identifiers('$1'), $k);
+ }
+ else
+ {
+ $k = $this->_protect_identifiers($k);
+ }
+ }
+
if ( ! $this->_has_operator($k))
{
$k .= ' =';
}
-
+
$v = ' '.$this->escape($v);
}
@@ -358,7 +488,7 @@ class CI_DB_active_record extends CI_DB_driver {
$prefix = (count($this->ar_where) == 0) ? '' : $type;
- $this->ar_where[] = $prefix.$key.$not . " IN (" . implode(", ", $this->ar_wherein) . ") ";
+ $this->ar_where[] = $prefix . $this->_protect_identifiers($key) . $not . " IN (" . implode(", ", $this->ar_wherein) . ") ";
return $this;
}
@@ -470,6 +600,8 @@ class CI_DB_active_record extends CI_DB_driver {
foreach ($field as $k => $v)
{
+ $k = $this->_protect_identifiers($k);
+
$prefix = (count($this->ar_like) == 0) ? '' : $type;
$v = $this->escape_str($v);
@@ -511,7 +643,7 @@ class CI_DB_active_record extends CI_DB_driver {
$val = trim($val);
if ($val != '')
- $this->ar_groupby[] = $this->dbprefix.$val;
+ $this->ar_groupby[] = $this->_protect_identifiers($val);
}
return $this;
}
@@ -617,7 +749,7 @@ class CI_DB_active_record extends CI_DB_driver {
$direction = (in_array(strtoupper(trim($direction)), array('ASC', 'DESC'), TRUE)) ? ' '.$direction : ' ASC';
}
- $this->ar_orderby[] = $orderby.$direction;
+ $this->ar_orderby[] = $this->_protect_identifiers($orderby).$direction;
return $this;
}
@@ -676,9 +808,10 @@ class CI_DB_active_record extends CI_DB_driver {
* @access public
* @param mixed
* @param string
+ * @param boolean
* @return object
*/
- function set($key, $value = '')
+ function set($key, $value = '', $escape = TRUE)
{
$key = $this->_object_to_array($key);
@@ -689,7 +822,15 @@ class CI_DB_active_record extends CI_DB_driver {
foreach ($key as $k => $v)
{
- $this->ar_set[$k] = $this->escape($v);
+ if ($escape === FALSE)
+ {
+ $this->ar_set[$this->_protect_identifiers($k)] = $v;
+ }
+ else
+ {
+ $this->ar_set[$this->_protect_identifiers($k)] = $this->escape($v);
+ }
+
}
return $this;
@@ -729,8 +870,6 @@ class CI_DB_active_record extends CI_DB_driver {
return $result;
}
- // --------------------------------------------------------------------
-
/**
* "Count All Results" query
*
@@ -749,7 +888,7 @@ class CI_DB_active_record extends CI_DB_driver {
$this->from($table);
}
- $sql = $this->_compile_select($this->_count_string);
+ $sql = $this->_compile_select($this->_count_string . $this->_protect_identifiers('numrows'));
$query = $this->query($sql);
$this->_reset_select();
@@ -854,8 +993,8 @@ class CI_DB_active_record extends CI_DB_driver {
$table = $this->ar_from[0];
}
-
- $sql = $this->_insert($this->dbprefix.$table, array_keys($this->ar_set), array_values($this->ar_set));
+
+ $sql = $this->_insert($this->_protect_identifiers($this->dbprefix.$table), array_keys($this->ar_set), array_values($this->ar_set));
$this->_reset_write();
return $this->query($sql);
@@ -914,9 +1053,89 @@ class CI_DB_active_record extends CI_DB_driver {
$this->limit($limit);
}
- $sql = $this->_update($this->dbprefix.$table, $this->ar_set, $this->ar_where, $this->ar_limit);
+ $sql = $this->_update($this->_protect_identifiers($this->dbprefix.$table), $this->ar_set, $this->ar_where, $this->ar_orderby, $this->ar_limit);
+
+ $this->_reset_write();
+ return $this->query($sql);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Empty Table
+ *
+ * Compiles a delete string and runs "DELETE FROM table"
+ *
+ * @access public
+ * @param string the table to empty
+ * @return object
+ */
+ function empty_table($table = '')
+ {
+ if ($table == '')
+ {
+ if ( ! isset($this->ar_from[0]))
+ {
+ if ($this->db_debug)
+ {
+ return $this->display_error('db_must_set_table');
+ }
+ return FALSE;
+ }
+
+ $table = $this->ar_from[0];
+ }
+ else
+ {
+ $table = $this->_protect_identifiers($this->dbprefix.$table);
+ }
+
+
+ $sql = $this->_delete($table);
+
+ $this->_reset_write();
+ return $this->query($sql);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Truncate
+ *
+ * Compiles a truncate string and runs the query
+ * If the database does not support the truncate() command
+ * This function maps to "DELETE FROM table"
+ *
+ * @access public
+ * @param string the table to truncate
+ * @return object
+ */
+ function truncate($table = '')
+ {
+ if ($table == '')
+ {
+ if ( ! isset($this->ar_from[0]))
+ {
+ if ($this->db_debug)
+ {
+ return $this->display_error('db_must_set_table');
+ }
+ return FALSE;
+ }
+
+ $table = $this->ar_from[0];
+ }
+ else
+ {
+ $table = $this->_protect_identifiers($this->dbprefix.$table);
+ }
+
+
+ $sql = $this->_truncate($table);
+
$this->_reset_write();
+
return $this->query($sql);
}
@@ -946,19 +1165,23 @@ class CI_DB_active_record extends CI_DB_driver {
}
return FALSE;
}
-
+
$table = $this->ar_from[0];
}
-
- if (is_array($table))
+ elseif (is_array($table))
{
foreach($table as $single_table)
{
- $this->delete($this->dbprefix.$single_table, $where, $limit, FALSE);
+ $this->delete($single_table, $where, $limit, FALSE);
}
+
$this->_reset_write();
return;
}
+ else
+ {
+ $table = $this->_protect_identifiers($this->dbprefix.$table);
+ }
if ($where != '')
{
@@ -970,21 +1193,23 @@ class CI_DB_active_record extends CI_DB_driver {
$this->limit($limit);
}
- if (count($this->ar_where) == 0)
+ if (count($this->ar_where) == 0 && count($this->ar_like) == 0)
{
if ($this->db_debug)
{
return $this->display_error('db_del_must_use_where');
}
+
return FALSE;
}
- $sql = $this->_delete($this->dbprefix.$table, $this->ar_where, $this->ar_limit);
+ $sql = $this->_delete($table, $this->ar_where, $this->ar_like, $this->ar_limit);
if ($reset_data)
{
$this->_reset_write();
}
+
return $this->query($sql);
}
@@ -1038,9 +1263,9 @@ class CI_DB_active_record extends CI_DB_driver {
if (strpos($table, " ") !== FALSE)
{
// if the alias is written with the AS keyowrd, get it out
- $table = preg_replace('/AS/i', '', $table);
+ $table = preg_replace('/ AS /i', ' ', $table);
- $this->ar_aliased_tables[] = trim(strrchr($table, " ") . '.');
+ $this->ar_aliased_tables[] = trim(strrchr($table, " "));
}
return $this->dbprefix.$table;
@@ -1059,23 +1284,20 @@ class CI_DB_active_record extends CI_DB_driver {
*/
function _filter_table_aliases($statements)
{
- $filter_tables_with_aliases = array();
+ $statements_without_aliases = array();
- foreach ($statements as $statement)
+ foreach ($statements as $k => $v)
{
- $tables_with_dbprefix = array();
-
- foreach ($this->ar_aliased_tables as $k => $v)
+ foreach ($this->ar_aliased_tables as $table)
{
- $tables_with_dbprefix[$k] = '/'.$this->dbprefix.str_replace('.', '', $v).'\./';
+ $statement = preg_replace('/(\w+\.\w+)/', $this->_protect_identifiers('$0'), $v); // makes `table.field`
+ $statement = str_replace(array($this->dbprefix.$table, '.'), array($table, $this->_protect_identifiers('.')), $statement);
}
- $statement = preg_replace($tables_with_dbprefix, $this->ar_aliased_tables, $statement);
-
- $filter_tables_with_aliases[] = $statement;
+ $statements[$k] = $statement;
}
- return $filter_tables_with_aliases;
+ return $statements;
}
// --------------------------------------------------------------------
@@ -1254,7 +1476,10 @@ class CI_DB_active_record extends CI_DB_driver {
$this->ar_set = array();
$this->ar_from = array();
$this->ar_where = array();
+ $this->ar_like = array();
$this->ar_limit = FALSE;
+ $this->ar_order = FALSE;
+ $this->ar_orderby = array();
}
}
diff --git a/system/database/DB_cache.php b/system/database/DB_cache.php
index 1e7410708..77b951500 100644
--- a/system/database/DB_cache.php
+++ b/system/database/DB_cache.php
@@ -63,14 +63,12 @@ class CI_DB_Cache {
// Add a trailing slash to the path if needed
$path = preg_replace("/(.+?)\/*$/", "\\1/", $path);
-
- if ( ! is_dir($path) OR ! is_writable($path))
+
+ // Load the file helper
+ $this->CI->load->helper('file');
+
+ if ( ! is_dir($path) OR ! is_really_writable($path))
{
- if ($this->CI->db->db_debug)
- {
- return $this->CI->db->display_error('db_invalid_cache_path');
- }
-
// If the path is wrong we'll turn off caching
return $this->CI->db->cache_off();
}
diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php
index a7f03e3e5..c2fa70a72 100644
--- a/system/database/DB_driver.php
+++ b/system/database/DB_driver.php
@@ -36,6 +36,8 @@ class CI_DB_driver {
var $database;
var $dbdriver = 'mysql';
var $dbprefix = '';
+ var $autoinit = TRUE; // Whether to automatically initialize the DB
+ var $swap_pre = '';
var $port = '';
var $pconnect = FALSE;
var $conn_id = FALSE;
@@ -76,41 +78,11 @@ class CI_DB_driver {
*/
function CI_DB_driver($params)
{
- $this->initialize($params);
- log_message('debug', 'Database Driver Class Initialized');
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Initialize Database Settings
- *
- * @access private Called by the constructor
- * @param mixed
- * @return void
- */
- function initialize($params = '')
- {
if (is_array($params))
{
- $defaults = array(
- 'hostname' => '',
- 'username' => '',
- 'password' => '',
- 'database' => '',
- 'conn_id' => FALSE,
- 'dbdriver' => 'mysql',
- 'dbprefix' => '',
- 'port' => '',
- 'pconnect' => FALSE,
- 'db_debug' => FALSE,
- 'cachedir' => '',
- 'cache_on' => FALSE
- );
-
- foreach ($defaults as $key => $val)
+ foreach ($params as $key => $val)
{
- $this->$key = ( ! isset($params[$key])) ? $val : $params[$key];
+ $this->$key = $val;
}
}
elseif (strpos($params, '://'))
@@ -131,7 +103,21 @@ class CI_DB_driver {
$this->password = ( ! isset($dsn['pass'])) ? '' : rawurldecode($dsn['pass']);
$this->database = ( ! isset($dsn['path'])) ? '' : rawurldecode(substr($dsn['path'], 1));
}
-
+
+ log_message('debug', 'Database Driver Class Initialized');
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Initialize Database Settings
+ *
+ * @access private Called by the constructor
+ * @param mixed
+ * @return void
+ */
+ function initialize($create_db = FALSE)
+ {
// If an existing DB connection resource is supplied
// there is no need to connect and select the database
if (is_resource($this->conn_id))
@@ -159,6 +145,46 @@ class CI_DB_driver {
{
if ( ! $this->db_select())
{
+ // Should we attempt to create the database?
+ if ($create_db == TRUE)
+ {
+ // Load the DB utility class
+ $CI =& get_instance();
+ $CI->load->dbutil();
+
+ // Create the DB
+ if ( ! $CI->dbutil->create_database($this->database))
+ {
+ log_message('error', 'Unable to create database: '.$this->database);
+
+ if ($this->db_debug)
+ {
+ $this->display_error('db_unable_to_create', $this->database);
+ }
+ return FALSE;
+ }
+ else
+ {
+ // In the event the DB was created we need to select it
+ if ($this->db_select())
+ {
+ if (! $this->db_set_charset($this->char_set, $this->dbcollat))
+ {
+ log_message('error', 'Unable to set database connection charset: '.$this->char_set);
+
+ if ($this->db_debug)
+ {
+ $this->display_error('db_unable_to_set_charset', $this->char_set);
+ }
+
+ return FALSE;
+ }
+
+ return TRUE;
+ }
+ }
+ }
+
log_message('error', 'Unable to select database: '.$this->database);
if ($this->db_debug)
@@ -167,6 +193,18 @@ class CI_DB_driver {
}
return FALSE;
}
+
+ if (! $this->db_set_charset($this->char_set, $this->dbcollat))
+ {
+ log_message('error', 'Unable to set database connection charset: '.$this->char_set);
+
+ if ($this->db_debug)
+ {
+ $this->display_error('db_unable_to_set_charset', $this->char_set);
+ }
+
+ return FALSE;
+ }
}
return TRUE;
@@ -211,8 +249,7 @@ class CI_DB_driver {
}
$query = $this->query($sql);
- $row = $query->row();
- return $row->ver;
+ return $query->row('ver');
}
// --------------------------------------------------------------------
@@ -242,6 +279,12 @@ class CI_DB_driver {
}
return FALSE;
}
+
+ // Verify table prefix and replace if necessary
+ if ( ($this->dbprefix != '' AND $this->swap_pre != '') AND ($this->dbprefix != $this->swap_pre) )
+ {
+ $sql = preg_replace("/(\W)".$this->swap_pre."(\S+?)/", "\\1".$this->dbprefix."\\2", $sql);
+ }
// Is query caching enabled? If the query is a "read type"
// we will load the caching class and return the previously
@@ -269,7 +312,7 @@ class CI_DB_driver {
{
$this->queries[] = $sql;
}
-
+
// Start the Query Timer
$time_start = list($sm, $ss) = explode(' ', microtime());
@@ -291,7 +334,7 @@ class CI_DB_driver {
);
}
- return FALSE;
+ return FALSE;
}
// Stop and aggregate the query time results
@@ -329,6 +372,7 @@ class CI_DB_driver {
$RES = new $driver();
$RES->conn_id = $this->conn_id;
$RES->result_id = $this->result_id;
+ $RES->num_rows = $RES->num_rows();
if ($this->dbdriver == 'oci8')
{
@@ -336,9 +380,7 @@ class CI_DB_driver {
$RES->curs_id = NULL;
$RES->limit_used = $this->limit_used;
}
-
- $RES->num_rows = $RES->num_rows();
-
+
// Is query caching enabled? If so, we'll serialize the
// result object and save it to a cache file.
if ($this->cache_on == TRUE AND $this->_cache_init())
@@ -593,6 +635,23 @@ class CI_DB_driver {
// --------------------------------------------------------------------
/**
+ * Protect Identifiers
+ *
+ * This function adds backticks if appropriate based on db type
+ *
+ * @access private
+ * @param mixed the item to escape
+ * @param boolean only affect the first word
+ * @return mixed the item with backticks
+ */
+ function protect_identifiers($item, $first_word_only = FALSE)
+ {
+ return $this->_protect_identifiers($item, $first_word_only = FALSE);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
* "Smart" Escape String
*
* Escapes data based on type
@@ -649,7 +708,7 @@ class CI_DB_driver {
* @access public
* @return array
*/
- function list_tables()
+ function list_tables($constrain_by_prefix = FALSE)
{
// Is there a cached result?
if (isset($this->data_cache['table_names']))
@@ -657,7 +716,7 @@ class CI_DB_driver {
return $this->data_cache['table_names'];
}
- if (FALSE === ($sql = $this->_list_tables()))
+ if (FALSE === ($sql = $this->_list_tables($constrain_by_prefix)))
{
if ($this->db_debug)
{
@@ -697,7 +756,7 @@ class CI_DB_driver {
*/
function table_exists($table_name)
{
- return ( ! in_array($this->dbprefix.$table_name, $this->list_tables())) ? FALSE : TRUE;
+ return ( ! in_array($this->prep_tablename($table_name), $this->list_tables())) ? FALSE : TRUE;
}
// --------------------------------------------------------------------
@@ -726,7 +785,7 @@ class CI_DB_driver {
return FALSE;
}
- if (FALSE === ($sql = $this->_list_columns($this->dbprefix.$table)))
+ if (FALSE === ($sql = $this->_list_columns($this->prep_tablename($table))))
{
if ($this->db_debug)
{
@@ -798,7 +857,7 @@ class CI_DB_driver {
return FALSE;
}
- $query = $this->query($this->_field_data($this->dbprefix.$table));
+ $query = $this->query($this->_field_data($this->prep_tablename($table)));
return $query->field_data();
}
@@ -822,9 +881,10 @@ class CI_DB_driver {
$fields[] = $key;
$values[] = $this->escape($val);
}
-
- return $this->_insert($this->dbprefix.$table, $fields, $values);
- }
+
+
+ return $this->_insert($this->prep_tablename($table), $fields, $values);
+ }
// --------------------------------------------------------------------
@@ -859,7 +919,7 @@ class CI_DB_driver {
{
$prefix = (count($dest) == 0) ? '' : ' AND ';
- if ($val != '')
+ if ($val !== '')
{
if ( ! $this->_has_operator($key))
{
@@ -873,12 +933,35 @@ class CI_DB_driver {
}
}
- return $this->_update($this->dbprefix.$table, $fields, $dest);
+ return $this->_update($this->prep_tablename($table), $fields, $dest);
}
// --------------------------------------------------------------------
/**
+ * Prep the table name - simply adds the table prefix if needed
+ *
+ * @access public
+ * @param string the table name
+ * @return string
+ */
+ function prep_tablename($table = '')
+ {
+ // Do we need to add the table prefix?
+ if ($this->dbprefix != '')
+ {
+ if (substr($table, 0, strlen($this->dbprefix)) != $this->dbprefix)
+ {
+ $table = $this->dbprefix.$table;
+ }
+ }
+
+ return $table;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
* Enables a native PHP function to be run, using a platform agnostic wrapper.
*
* @access public
@@ -1013,7 +1096,6 @@ class CI_DB_driver {
return TRUE;
}
-
// --------------------------------------------------------------------
/**
@@ -1044,6 +1126,7 @@ class CI_DB_driver {
*/
function display_error($error = '', $swap = '', $native = FALSE)
{
+// $LANG = new CI_Lang();
$LANG = new CI_Language();
$LANG->load('db');
@@ -1060,6 +1143,7 @@ class CI_DB_driver {
if ( ! class_exists('CI_Exceptions'))
{
+// include(BASEPATH.'core/Exceptions'.EXT);
include(BASEPATH.'libraries/Exceptions'.EXT);
}
diff --git a/system/database/DB_forge.php b/system/database/DB_forge.php
new file mode 100644
index 000000000..d02589457
--- /dev/null
+++ b/system/database/DB_forge.php
@@ -0,0 +1,323 @@
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * Code Igniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeigniter.com/user_guide/license.html
+ * @link http://www.codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Database Utility Class
+ *
+ * @category Database
+ * @author Rick Ellis
+ * @link http://www.codeigniter.com/user_guide/database/
+ */
+class CI_DB_forge {
+
+ var $fields = array();
+ var $keys = array();
+ var $primary_keys = array();
+ var $db_char_set = '';
+
+ /**
+ * Constructor
+ *
+ * Grabs the CI super object instance so we can access it.
+ *
+ */
+ function CI_DB_forge()
+ {
+ // Assign the main database object to $this->db
+ $CI =& get_instance();
+ $this->db =& $CI->db;
+
+ log_message('debug', "Database Forge Class Initialized");
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Create database
+ *
+ * @access public
+ * @param string the database name
+ * @return bool
+ */
+ function create_database($db_name)
+ {
+ $sql = $this->_create_database($db_name);
+
+ if (is_bool($sql))
+ {
+ return $sql;
+ }
+
+ return $this->db->query($sql);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Drop database
+ *
+ * @access public
+ * @param string the database name
+ * @return bool
+ */
+ function drop_database($db_name)
+ {
+ $sql = $this->_drop_database($db_name);
+
+ if (is_bool($sql))
+ {
+ return $sql;
+ }
+
+ return $this->db->query($sql);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Add Key
+ *
+ * @access public
+ * @param string key
+ * @param string type
+ * @return void
+ */
+ function add_key($key = '', $primary = FALSE)
+ {
+ if ($key == '')
+ {
+ show_error('Key information is required for that operation.');
+ }
+
+ if ($primary === TRUE)
+ {
+ $this->primary_keys[] = $key;
+ }
+ else
+ {
+ $this->keys[] = $key;
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Add Field
+ *
+ * @access public
+ * @param string collation
+ * @return void
+ */
+ function add_field($field = '')
+ {
+ if ($field == '')
+ {
+ show_error('Field information is required.');
+ }
+
+ if (is_string($field))
+ {
+ if ($field == 'id')
+ {
+ $this->fields[] = array('id' => array(
+ 'type' => 'INT',
+ 'constraint' => 9,
+ 'auto_increment' => TRUE
+ )
+ );
+ $this->add_key('id', TRUE);
+ }
+ else
+ {
+ if (strpos($field, ' ') === FALSE)
+ {
+ show_error('Field information is required for that operation.');
+ }
+
+ $this->fields[] = $field;
+ }
+ }
+
+ if (is_array($field))
+ {
+ $this->fields = array_merge($this->fields, $field);
+ }
+
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Create Table
+ *
+ * @access public
+ * @param string the table name
+ * @return bool
+ */
+ function create_table($table = '', $if_not_exists = FALSE)
+ {
+ if ($table == '')
+ {
+ show_error('A table name is required for that operation.');
+ }
+
+ if (count($this->fields) == 0)
+ {
+ show_error('Field information is required.');
+ }
+
+ $sql = $this->_create_table($table, $this->fields, $this->primary_keys, $this->keys, $if_not_exists);
+
+ $this->_reset();
+ return $this->db->query($sql);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Drop Table
+ *
+ * @access public
+ * @param string the table name
+ * @return bool
+ */
+ function drop_table($table_name)
+ {
+ $sql = $this->_drop_table($table_name);
+
+ if (is_bool($sql))
+ {
+ return $sql;
+ }
+
+ return $this->db->query($sql);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Column Add
+ *
+ * @access public
+ * @param string the table name
+ * @param string the column name
+ * @param string the column definition
+ * @return bool
+ */
+ function add_column($table = '', $field = array(), $after_field = '')
+ {
+ if ($table == '')
+ {
+ show_error('A table name is required for that operation.');
+ }
+
+ // add field info into field array, but we can only do one at a time
+ // so only grab the first field in the event there are more then one
+ $this->add_field(array_slice($field, 0, 1));
+
+ if (count($this->fields) == 0)
+ {
+ show_error('Field information is required.');
+ }
+
+ $sql = $this->_alter_table('ADD', $table, $this->fields, $after_field);
+
+ $this->_reset();
+ return $this->db->query($sql);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Column Drop
+ *
+ * @access public
+ * @param string the table name
+ * @param string the column name
+ * @return bool
+ */
+ function drop_column($table = '', $column_name = '')
+ {
+
+ if ($table == '')
+ {
+ show_error('A table name is required for that operation.');
+ }
+
+ if ($column_name == '')
+ {
+ show_error('A column name is required for that operation.');
+ }
+
+ $sql = $this->_alter_table('DROP', $table, $column_name);
+
+ return $this->db->query($sql);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Column Modify
+ *
+ * @access public
+ * @param string the table name
+ * @param string the column name
+ * @param string the column definition
+ * @return bool
+ */
+ function modify_column($table = '', $field = array())
+ {
+
+ if ($table == '')
+ {
+ show_error('A table name is required for that operation.');
+ }
+
+ // add field info into field array, but we can only do one at a time
+ // so only grab the first field in the event there are more then one
+ $this->add_field(array_slice($field, 0, 1));
+
+ if (count($this->fields) == 0)
+ {
+ show_error('Field information is required.');
+ }
+
+ $sql = $this->_alter_table('CHANGE', $table, $this->fields);
+
+ $this->_reset();
+ return $this->db->query($sql);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Reset
+ *
+ * Resets table creation vars
+ *
+ * @access private
+ * @return void
+ */
+ function _reset()
+ {
+ $this->fields = array();
+ $this->keys = array();
+ $this->primary_keys = array();
+ }
+
+}
+?> \ No newline at end of file
diff --git a/system/database/DB_result.php b/system/database/DB_result.php
index b438ad1d8..36eddd840 100644
--- a/system/database/DB_result.php
+++ b/system/database/DB_result.php
@@ -34,6 +34,7 @@ class CI_DB_result {
var $result_object = array();
var $current_row = 0;
var $num_rows = 0;
+ var $row_data = NULL;
/**
@@ -118,17 +119,66 @@ class CI_DB_result {
* Query result. Acts as a wrapper function for the following functions.
*
* @access public
+ * @param string
* @param string can be "object" or "array"
* @return mixed either a result object or array
*/
function row($n = 0, $type = 'object')
{
+ if ( ! is_numeric($n))
+ {
+ // We cache the row data for subsequent uses
+ if ( ! is_array($this->row_data))
+ {
+ $this->row_data = $this->row_array(0);
+ }
+
+ if (isset($this->row_data[$n]))
+ {
+ return $this->row_data[$n];
+ }
+ // reset the $n variable if the result was not achieved
+ $n = 0;
+ }
+
return ($type == 'object') ? $this->row_object($n) : $this->row_array($n);
}
// --------------------------------------------------------------------
/**
+ * Assigns an item into a particular column slot
+ *
+ * @access public
+ * @return object
+ */
+ function set_row($key, $value = NULL)
+ {
+ // We cache the row data for subsequent uses
+ if ( ! is_array($this->row_data))
+ {
+ $this->row_data = $this->row_array(0);
+ }
+
+ if (is_array($key))
+ {
+ foreach ($key as $k => $v)
+ {
+ $this->row_data[$k] = $v;
+ }
+
+ return;
+ }
+
+ if ($key != '' AND ! is_null($value))
+ {
+ $this->row_data[$key] = $value;
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
* Returns a single result row - object version
*
* @access public
diff --git a/system/database/DB_utility.php b/system/database/DB_utility.php
index e9caf9f3e..372c88f1f 100644
--- a/system/database/DB_utility.php
+++ b/system/database/DB_utility.php
@@ -6,7 +6,7 @@
*
* @package CodeIgniter
* @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
* @license http://www.codeigniter.com/user_guide/license.html
* @link http://www.codeigniter.com
* @since Version 1.0
@@ -22,10 +22,10 @@
* @author Rick Ellis
* @link http://www.codeigniter.com/user_guide/database/
*/
-class CI_DB_utility {
+class CI_DB_utility extends CI_DB_forge {
var $db;
- var $data_cache = array();
+ var $data_cache = array();
/**
* Constructor
@@ -45,48 +45,6 @@ class CI_DB_utility {
// --------------------------------------------------------------------
/**
- * Create database
- *
- * @access public
- * @param string the database name
- * @return bool
- */
- function create_database($db_name)
- {
- $sql = $this->_create_database($db_name);
-
- if (is_bool($sql))
- {
- return $sql;
- }
-
- return $this->db->query($sql);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Drop database
- *
- * @access public
- * @param string the database name
- * @return bool
- */
- function drop_database($db_name)
- {
- $sql = $this->_drop_database($db_name);
-
- if (is_bool($sql))
- {
- return $sql;
- }
-
- return $this->db->query($sql);
- }
-
- // --------------------------------------------------------------------
-
- /**
* List databases
*
* @access public
@@ -129,7 +87,7 @@ class CI_DB_utility {
if (is_bool($sql))
{
- return $sql;
+ show_error('db_must_use_set');
}
$query = $this->db->query($sql);
@@ -180,13 +138,12 @@ class CI_DB_utility {
// --------------------------------------------------------------------
/**
- * Optimize Table
+ * Repair Table
*
* @access public
* @param string the table name
* @return bool
*/
-
function repair_table($table_name)
{
$sql = $this->_repair_table($table_name);
@@ -203,28 +160,7 @@ class CI_DB_utility {
$res = $query->result_array();
return current($res);
}
-
- // --------------------------------------------------------------------
-
- /**
- * Drop Table
- *
- * @access public
- * @param string the table name
- * @return bool
- */
- function drop_table($table_name)
- {
- $sql = $this->_drop_table($table_name);
-
- if (is_bool($sql))
- {
- return $sql;
- }
- return $this->db->query($sql);
- }
-
// --------------------------------------------------------------------
/**
@@ -445,11 +381,6 @@ class CI_DB_utility {
}
-
-
-
-
-
}
?> \ No newline at end of file
diff --git a/system/database/drivers/mssql/mssql_driver.php b/system/database/drivers/mssql/mssql_driver.php
index 044fb3ced..06a508e71 100644
--- a/system/database/drivers/mssql/mssql_driver.php
+++ b/system/database/drivers/mssql/mssql_driver.php
@@ -35,7 +35,8 @@ class CI_DB_mssql_driver extends CI_DB {
* database engines, so this string appears in each driver and is
* used for the count_all() and count_all_results() functions.
*/
- var $_count_string = "SELECT COUNT(*) AS numrows ";
+ var $_count_string = "SELECT COUNT(*) AS ";
+ var $_random_keyword = ' ASC'; // not currently supported
/**
* Non-persistent database connection
@@ -77,6 +78,22 @@ class CI_DB_mssql_driver extends CI_DB {
// --------------------------------------------------------------------
/**
+ * Set client character set
+ *
+ * @access public
+ * @param string
+ * @param string
+ * @return resource
+ */
+ function db_set_charset($charset, $collation)
+ {
+ // TODO - add support if needed
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
* Execute the query
*
* @access private called by the base class
@@ -297,11 +314,21 @@ class CI_DB_mssql_driver extends CI_DB {
* Generates a platform-specific query string so that the table names can be fetched
*
* @access private
+ * @param boolean
* @return string
*/
- function _list_tables()
+ function _list_tables($prefix_limit = FALSE)
{
- return "SELECT name FROM sysobjects WHERE type = 'U' ORDER BY name";
+ $sql = "SELECT name FROM sysobjects WHERE type = 'U' ORDER BY name";
+
+ // for future compatibility
+ if ($prefix_limit !== FALSE AND $this->dbprefix != '')
+ {
+ //$sql .= " LIKE '".$this->dbprefix."%'";
+ return FALSE; // not currently supported
+ }
+
+ return $sql;
}
// --------------------------------------------------------------------
@@ -393,6 +420,25 @@ class CI_DB_mssql_driver extends CI_DB {
// --------------------------------------------------------------------
/**
+ * Protect Identifiers
+ *
+ * This function adds backticks if appropriate based on db type
+ *
+ * @access private
+ * @param mixed the item(s)
+ * @param boolean should spaces be backticked
+ * @param boolean only affect the first word
+ * @return mixed the item with backticks
+ */
+ function _protect_identifiers($item, $affect_spaces = TRUE, $first_word_only = FALSE)
+ {
+ // MSSQL doesn't use backticks
+ return $item;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
* Insert statement
*
* Generates a platform-specific insert string from the supplied data
@@ -419,9 +465,11 @@ class CI_DB_mssql_driver extends CI_DB {
* @param string the table name
* @param array the update data
* @param array the where clause
+ * @param array the orderby clause
+ * @param array the limit clause
* @return string
*/
- function _update($table, $values, $where, $limit = FALSE)
+ function _update($table, $values, $where, $orderby = array(), $limit = FALSE)
{
foreach($values as $key => $val)
{
@@ -429,8 +477,29 @@ class CI_DB_mssql_driver extends CI_DB {
}
$limit = (!$limit) ? '' : ' LIMIT '.$limit;
+
+ $orderby = (count($orderby) >= 1)?' ORDER BY '.implode(", ", $orderby):'';
- return "UPDATE ".$this->_escape_table($table)." SET ".implode(', ', $valstr)." WHERE ".implode(" ", $where).$limit;
+ return "UPDATE ".$this->_escape_table($table)." SET ".implode(', ', $valstr)." WHERE ".implode(" ", $where).$orderby.$limit;
+ }
+
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Truncate statement
+ *
+ * Generates a platform-specific truncate string from the supplied data
+ * If the database does not support the truncate() command
+ * This function maps to "DELETE FROM table"
+ *
+ * @access public
+ * @param string the table name
+ * @return string
+ */
+ function _truncate($table)
+ {
+ return "TRUNCATE ".$this->_escape_table($table);
}
// --------------------------------------------------------------------
@@ -443,13 +512,28 @@ class CI_DB_mssql_driver extends CI_DB {
* @access public
* @param string the table name
* @param array the where clause
+ * @param string the limit clause
* @return string
*/
- function _delete($table, $where, $limit = FALSE)
+ function _delete($table, $where = array(), $like = array(), $limit = FALSE)
{
+ $conditions = '';
+
+ if (count($where) > 0 || count($like) > 0)
+ {
+ $conditions = "\nWHERE ";
+ $conditions .= implode("\n", $this->ar_where);
+
+ if (count($where) > 0 && count($like) > 0)
+ {
+ $conditions .= " AND ";
+ }
+ $conditions .= implode("\n", $like);
+ }
+
$limit = (!$limit) ? '' : ' LIMIT '.$limit;
- return "DELETE FROM ".$this->_escape_table($table)." WHERE ".implode(" ", $where).$limit;
+ return "DELETE FROM ".$table.$conditions.$limit;
}
// --------------------------------------------------------------------
diff --git a/system/database/drivers/mssql/mssql_forge.php b/system/database/drivers/mssql/mssql_forge.php
new file mode 100644
index 000000000..63a9d8396
--- /dev/null
+++ b/system/database/drivers/mssql/mssql_forge.php
@@ -0,0 +1,219 @@
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeigniter.com/user_guide/license.html
+ * @link http://www.codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * MS SQL Forge Class
+ *
+ * @category Database
+ * @author Rick Ellis
+ * @link http://www.codeigniter.com/user_guide/database/
+ */
+class CI_DB_mssql_forge extends CI_DB_forge {
+
+ /**
+ * Create database
+ *
+ * @access private
+ * @param string the database name
+ * @return bool
+ */
+ function _create_database($name)
+ {
+ return "CREATE DATABASE ".$name;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Drop database
+ *
+ * @access private
+ * @param string the database name
+ * @return bool
+ */
+ function _drop_database($name)
+ {
+ return "DROP DATABASE ".$name;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Drop Table
+ *
+ * @access private
+ * @return bool
+ */
+ function _drop_table($table)
+ {
+ return "DROP TABLE ".$this->db->_escape_table($table);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Create Table
+ *
+ * @access private
+ * @param string the table name
+ * @param array the fields
+ * @param mixed primary key(s)
+ * @param mixed key(s)
+ * @param boolean should 'IF NOT EXISTS' be added to the SQL
+ * @return bool
+ */
+ function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists)
+ {
+ $sql = 'CREATE TABLE ';
+
+ if ($if_not_exists === TRUE)
+ {
+ $sql .= 'IF NOT EXISTS ';
+ }
+
+ $sql .= $this->db->_escape_table($table)." (";
+ $current_field_count = 0;
+
+ foreach ($fields as $field=>$attributes)
+ {
+ // Numeric field names aren't allowed in databases, so if the key is
+ // numeric, we know it was assigned by PHP and the developer manually
+ // entered the field information, so we'll simply add it to the list
+ if (is_numeric($field))
+ {
+ $sql .= "\n\t$attributes";
+ }
+ else
+ {
+ $attributes = array_change_key_case($attributes, CASE_UPPER);
+
+ $sql .= "\n\t".$this->db->_protect_identifiers($field);
+
+ $sql .= ' '.$attributes['TYPE'];
+
+ if (array_key_exists('CONSTRAINT', $attributes))
+ {
+ $sql .= '('.$attributes['CONSTRAINT'].')';
+ }
+
+ if (array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE)
+ {
+ $sql .= ' UNSIGNED';
+ }
+
+ if (array_key_exists('DEFAULT', $attributes))
+ {
+ $sql .= ' DEFAULT \''.$attributes['DEFAULT'].'\'';
+ }
+
+ if (array_key_exists('NULL', $attributes) && $attributes['NULL'] === TRUE)
+ {
+ $sql .= ' NULL';
+ }
+ else
+ {
+ $sql .= ' NOT NULL';
+ }
+
+ if (array_key_exists('AUTO_INCREMENT', $attributes) && $attributes['AUTO_INCREMENT'] === TRUE)
+ {
+ $sql .= ' AUTO_INCREMENT';
+ }
+ }
+
+ // don't add a comma on the end of the last field
+ if (++$current_field_count < count($fields))
+ {
+ $sql .= ',';
+ }
+ }
+
+ if (count($primary_keys) > 0)
+ {
+ $primary_keys = $this->db->_protect_identifiers($primary_keys);
+ $sql .= ",\n\tPRIMARY KEY (" . implode(', ', $primary_keys) . ")";
+ }
+
+ if (is_array($keys) && count($keys) > 0)
+ {
+ $keys = $this->db->_protect_identifiers($keys);
+ foreach ($keys as $key)
+ {
+ $sql .= ",\n\tFOREIGN KEY ($key)";
+ }
+ }
+
+ $sql .= "\n)";
+
+ return $sql;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Alter table query
+ *
+ * Generates a platform-specific query so that a table can be altered
+ * Called by add_column(), drop_column(), and column_alter(),
+ *
+ * @access private
+ * @param string the ALTER type (ADD, DROP, CHANGE)
+ * @param string the column name
+ * @param string the table name
+ * @param string the column definition
+ * @param string the default value
+ * @param boolean should 'NOT NULL' be added
+ * @param string the field after which we should add the new field
+ * @return object
+ */
+ function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '')
+ {
+ $sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table)." $alter_type ".$this->db->_protect_identifiers($column_name);
+
+ // DROP has everything it needs now.
+ if ($alter_type == 'DROP')
+ {
+ return $sql;
+ }
+
+ $sql .= " $column_definition";
+
+ if ($default_value != '')
+ {
+ $sql .= " DEFAULT \"$default_value\"";
+ }
+
+ if ($null === NULL)
+ {
+ $sql .= ' NULL';
+ }
+ else
+ {
+ $sql .= ' NOT NULL';
+ }
+
+ if ($after_field != '')
+ {
+ $sql .= ' AFTER ' . $this->db->_protect_identifiers($after_field);
+ }
+
+ return $sql;
+
+ }
+
+}
+?> \ No newline at end of file
diff --git a/system/database/drivers/mssql/mssql_utility.php b/system/database/drivers/mssql/mssql_utility.php
index 3a102212b..b020a2a6e 100644
--- a/system/database/drivers/mssql/mssql_utility.php
+++ b/system/database/drivers/mssql/mssql_utility.php
@@ -24,48 +24,6 @@
*/
class CI_DB_mssql_utility extends CI_DB_utility {
-
- /**
- * Create database
- *
- * @access private
- * @param string the database name
- * @return bool
- */
- function _create_database($name)
- {
- return "CREATE DATABASE ".$name;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Drop database
- *
- * @access private
- * @param string the database name
- * @return bool
- */
- function _drop_database($name)
- {
- return "DROP DATABASE ".$name;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Drop Table
- *
- * @access private
- * @return bool
- */
- function _drop_table($table)
- {
- return "DROP TABLE ".$this->db->_escape_table($table);
- }
-
- // --------------------------------------------------------------------
-
/**
* List databases
*
@@ -94,7 +52,7 @@ class CI_DB_mssql_utility extends CI_DB_utility {
}
// --------------------------------------------------------------------
-
+
/**
* Repair table query
*
@@ -124,6 +82,39 @@ class CI_DB_mssql_utility extends CI_DB_utility {
return $this->db->display_error('db_unsuported_feature');
}
+ /**
+ *
+ * The functions below have been deprecated as of 1.6, and are only here for backwards
+ * compatibility. They now reside in dbforge(). The use of dbutils for database manipulation
+ * is STRONGLY discouraged in favour if using dbforge.
+ *
+ */
+
+ /**
+ * Create database
+ *
+ * @access private
+ * @param string the database name
+ * @return bool
+ */
+ function _create_database($name)
+ {
+ return "CREATE DATABASE ".$name;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Drop database
+ *
+ * @access private
+ * @param string the database name
+ * @return bool
+ */
+ function _drop_database($name)
+ {
+ return "DROP DATABASE ".$name;
+ }
}
diff --git a/system/database/drivers/mysql/mysql_driver.php b/system/database/drivers/mysql/mysql_driver.php
index cd86ebf52..a164552ed 100644
--- a/system/database/drivers/mysql/mysql_driver.php
+++ b/system/database/drivers/mysql/mysql_driver.php
@@ -42,7 +42,7 @@ class CI_DB_mysql_driver extends CI_DB {
* database engines, so this string appears in each driver and is
* used for the count_all() and count_all_results() functions.
*/
- var $_count_string = "SELECT COUNT(*) AS numrows ";
+ var $_count_string = 'SELECT COUNT(*) AS ';
var $_random_keyword = ' RAND()'; // database specific random keyword
/**
@@ -85,6 +85,21 @@ class CI_DB_mysql_driver extends CI_DB {
// --------------------------------------------------------------------
/**
+ * Set client character set
+ *
+ * @access public
+ * @param string
+ * @param string
+ * @return resource
+ */
+ function db_set_charset($charset, $collation)
+ {
+ return @mysql_query("SET NAMES '".$this->escape_str($charset)."' COLLATE '".$this->escape_str($collation)."'", $this->conn_id);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
* Version number query string
*
* @access public
@@ -314,17 +329,18 @@ class CI_DB_mysql_driver extends CI_DB {
* Generates a platform-specific query string so that the table names can be fetched
*
* @access private
+ * @param boolean
* @return string
*/
function _list_tables($prefix_limit = FALSE)
{
$sql = "SHOW TABLES FROM `".$this->database."`";
-
- if ($prefix_limit !== FALSE AND $this->_stdprefix != '')
+
+ if ($prefix_limit !== FALSE AND $this->dbprefix != '')
{
- $sql .= " LIKE '".$this->_stdprefix."%'";
+ $sql .= " LIKE '".$this->dbprefix."%'";
}
-
+
return $sql;
}
@@ -400,14 +416,66 @@ class CI_DB_mysql_driver extends CI_DB {
*/
function _escape_table($table)
{
- if (stristr($table, '.'))
+ if (strpos($table, '.') !== FALSE)
{
- $table = preg_replace("/\./", "`.`", $table);
+ $table = str_replace('.', '`.`', $table);
}
return $table;
}
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Protect Identifiers
+ *
+ * This function adds backticks if appropriate based on db type
+ *
+ * @access private
+ * @param mixed the item to escape
+ * @param boolean only affect the first word
+ * @return mixed the item with backticks
+ */
+ function _protect_identifiers($item, $first_word_only = FALSE)
+ {
+ if (is_array($item))
+ {
+ $escaped_array = array();
+
+ foreach($item as $k=>$v)
+ {
+ $escaped_array[$this->_protect_identifiers($k)] = $this->_protect_identifiers($v, $first_word_only);
+ }
+
+ return $escaped_array;
+ }
+
+ // This function may get "item1 item2" as a string, and so
+ // we may need "`item1` `item2`" and not "`item1 item2`"
+ if (strpos($item, ' ') !== FALSE)
+ {
+ // This function may get "field >= 1", and need it to return "`field` >= 1"
+ if ($first_word_only === TRUE)
+ {
+ return '`'.preg_replace('/ /', '` ', $item, 1);
+ }
+
+ $item = preg_replace('/(^|\s|\()([\w\d\-\_]+?)(\s|\)|$)/iS', '$1`$2`$3', $item);
+ }
+
+ $exceptions = array('AS', '/', '-', '%', '+', '*');
+
+ foreach ($exceptions as $exception)
+ {
+ if (stristr($item, " `{$exception}` ") !== FALSE)
+ {
+ $item = preg_replace('/ `('.preg_quote($exception).')` /i', ' $1 ', $item);
+ }
+ }
+ return $item;
+ }
+
// --------------------------------------------------------------------
/**
@@ -437,9 +505,11 @@ class CI_DB_mysql_driver extends CI_DB {
* @param string the table name
* @param array the update data
* @param array the where clause
+ * @param array the orderby clause
+ * @param array the limit clause
* @return string
*/
- function _update($table, $values, $where, $limit = FALSE)
+ function _update($table, $values, $where, $orderby = array(), $limit = FALSE)
{
foreach($values as $key => $val)
{
@@ -447,8 +517,28 @@ class CI_DB_mysql_driver extends CI_DB {
}
$limit = (!$limit) ? '' : ' LIMIT '.$limit;
+
+ $orderby = (count($orderby) >= 1)?' ORDER BY '.implode(", ", $orderby):'';
- return "UPDATE ".$this->_escape_table($table)." SET ".implode(', ', $valstr)." WHERE ".implode(" ", $where).$limit;
+ return "UPDATE ".$this->_escape_table($table)." SET ".implode(', ', $valstr)." WHERE ".implode(" ", $where).$orderby.$limit;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Truncate statement
+ *
+ * Generates a platform-specific truncate string from the supplied data
+ * If the database does not support the truncate() command
+ * This function maps to "DELETE FROM table"
+ *
+ * @access public
+ * @param string the table name
+ * @return string
+ */
+ function _truncate($table)
+ {
+ return "TRUNCATE ".$this->_escape_table($table);
}
// --------------------------------------------------------------------
@@ -461,13 +551,28 @@ class CI_DB_mysql_driver extends CI_DB {
* @access public
* @param string the table name
* @param array the where clause
+ * @param string the limit clause
* @return string
*/
- function _delete($table, $where, $limit = FALSE)
+ function _delete($table, $where = array(), $like = array(), $limit = FALSE)
{
+ $conditions = '';
+
+ if (count($where) > 0 || count($like) > 0)
+ {
+ $conditions = "\nWHERE ";
+ $conditions .= implode("\n", $this->ar_where);
+
+ if (count($where) > 0 && count($like) > 0)
+ {
+ $conditions .= " AND ";
+ }
+ $conditions .= implode("\n", $like);
+ }
+
$limit = (!$limit) ? '' : ' LIMIT '.$limit;
- return "DELETE FROM ".$this->_escape_table($table)." WHERE ".implode(" ", $where).$limit;
+ return "DELETE FROM ".$table.$conditions.$limit;
}
// --------------------------------------------------------------------
diff --git a/system/database/drivers/mysql/mysql_forge.php b/system/database/drivers/mysql/mysql_forge.php
new file mode 100644
index 000000000..8a918c026
--- /dev/null
+++ b/system/database/drivers/mysql/mysql_forge.php
@@ -0,0 +1,223 @@
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeigniter.com/user_guide/license.html
+ * @link http://www.codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * MySQL Forge Class
+ *
+ * @category Database
+ * @author Rick Ellis
+ * @link http://www.codeigniter.com/user_guide/database/
+ */
+class CI_DB_mysql_forge extends CI_DB_forge {
+
+ /**
+ * Create database
+ *
+ * @access private
+ * @param string the database name
+ * @return bool
+ */
+ function _create_database($name)
+ {
+ return "CREATE DATABASE ".$name;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Drop database
+ *
+ * @access private
+ * @param string the database name
+ * @return bool
+ */
+ function _drop_database($name)
+ {
+ return "DROP DATABASE ".$name;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Process Fields
+ *
+ * @access private
+ * @param mixed the fields
+ * @return string
+ */
+ function _process_fields($fields)
+ {
+ $current_field_count = 0;
+ $sql = '';
+
+ foreach ($fields as $field=>$attributes)
+ {
+ // Numeric field names aren't allowed in databases, so if the key is
+ // numeric, we know it was assigned by PHP and the developer manually
+ // entered the field information, so we'll simply add it to the list
+ if (is_numeric($field))
+ {
+ $sql .= "\n\t$attributes";
+ }
+ else
+ {
+ $attributes = array_change_key_case($attributes, CASE_UPPER);
+
+ $sql .= "\n\t".$this->db->_protect_identifiers($field);
+
+ if (array_key_exists('NAME', $attributes))
+ {
+ $sql .= ' '.$this->db->_protect_identifiers($attributes['NAME']).' ';
+ }
+
+ if (array_key_exists('TYPE', $attributes))
+ {
+ $sql .= ' '.$attributes['TYPE'];
+ }
+
+ if (array_key_exists('CONSTRAINT', $attributes))
+ {
+ $sql .= '('.$attributes['CONSTRAINT'].')';
+ }
+
+ if (array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE)
+ {
+ $sql .= ' UNSIGNED';
+ }
+
+ if (array_key_exists('DEFAULT', $attributes))
+ {
+ $sql .= ' DEFAULT \''.$attributes['DEFAULT'].'\'';
+ }
+
+ if (array_key_exists('NULL', $attributes))
+ {
+ $sql .= ($attributes['NULL'] === TRUE) ? ' NULL' : ' NOT NULL';
+ }
+
+ if (array_key_exists('AUTO_INCREMENT', $attributes) && $attributes['AUTO_INCREMENT'] === TRUE)
+ {
+ $sql .= ' AUTO_INCREMENT';
+ }
+ }
+
+ // don't add a comma on the end of the last field
+ if (++$current_field_count < count($fields))
+ {
+ $sql .= ',';
+ }
+ }
+
+ return $sql;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Create Table
+ *
+ * @access private
+ * @param string the table name
+ * @param mixed the fields
+ * @param mixed primary key(s)
+ * @param mixed key(s)
+ * @param boolean should 'IF NOT EXISTS' be added to the SQL
+ * @return bool
+ */
+ function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists)
+ {
+ $sql = 'CREATE TABLE ';
+
+ if ($if_not_exists === TRUE)
+ {
+ $sql .= 'IF NOT EXISTS ';
+ }
+
+ $sql .= $this->db->_escape_table($table)." (";
+
+ $sql .= $this->_process_fields($fields);
+
+ if (count($primary_keys) > 0)
+ {
+ $primary_keys = $this->db->_protect_identifiers($primary_keys);
+ $sql .= ",\n\tPRIMARY KEY (" . implode(', ', $primary_keys) . ")";
+ }
+
+ if (is_array($keys) && count($keys) > 0)
+ {
+ $keys = $this->db->_protect_identifiers($keys);
+ foreach ($keys as $key)
+ {
+ $sql .= ",\n\tKEY ($key)";
+ }
+ }
+
+ $sql .= "\n) DEFAULT CHARACTER SET {$this->db->char_set} COLLATE {$this->db->dbcollat};";
+
+ return $sql;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Drop Table
+ *
+ * @access private
+ * @return bool
+ */
+ function _drop_table($table)
+ {
+ return "DROP TABLE IF EXISTS ".$this->db->_escape_table($table);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Alter table query
+ *
+ * Generates a platform-specific query so that a table can be altered
+ * Called by add_column(), drop_column(), and column_alter(),
+ *
+ * @access private
+ * @param string the ALTER type (ADD, DROP, CHANGE)
+ * @param string the column name
+ * @param array fields
+ * @param string the field after which we should add the new field
+ * @return object
+ */
+ function _alter_table($alter_type, $table, $fields, $after_field = '')
+ {
+ $sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table)." $alter_type ";
+
+ // DROP has everything it needs now.
+ if ($alter_type == 'DROP')
+ {
+ return $sql.$this->db->_protect_identifiers($fields);
+ }
+
+ $sql .= $this->_process_fields($fields);
+
+ if ($after_field != '')
+ {
+ $sql .= ' AFTER ' . $this->db->_protect_identifiers($after_field);
+ }
+
+ return $sql;
+ }
+
+}
+?> \ No newline at end of file
diff --git a/system/database/drivers/mysql/mysql_utility.php b/system/database/drivers/mysql/mysql_utility.php
index 54c110e09..c24a008fa 100644
--- a/system/database/drivers/mysql/mysql_utility.php
+++ b/system/database/drivers/mysql/mysql_utility.php
@@ -23,34 +23,6 @@
* @link http://www.codeigniter.com/user_guide/database/
*/
class CI_DB_mysql_utility extends CI_DB_utility {
-
- /**
- * Create database
- *
- * @access private
- * @param string the database name
- * @return bool
- */
- function _create_database($name)
- {
- return "CREATE DATABASE ".$name;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Drop database
- *
- * @access private
- * @param string the database name
- * @return bool
- */
- function _drop_database($name)
- {
- return "DROP DATABASE ".$name;
- }
-
- // --------------------------------------------------------------------
/**
* List databases
@@ -66,19 +38,6 @@ class CI_DB_mysql_utility extends CI_DB_utility {
// --------------------------------------------------------------------
/**
- * Drop Table
- *
- * @access private
- * @return bool
- */
- function _drop_table($table)
- {
- return "DROP TABLE IF EXISTS ".$this->db->_escape_table($table);
- }
-
- // --------------------------------------------------------------------
-
- /**
* Optimize table query
*
* Generates a platform-specific query so that a table can be optimized
@@ -109,7 +68,6 @@ class CI_DB_mysql_utility extends CI_DB_utility {
}
// --------------------------------------------------------------------
-
/**
* MySQL Export
*
@@ -187,9 +145,10 @@ class CI_DB_mysql_utility extends CI_DB_utility {
$is_int = array();
while ($field = mysql_fetch_field($query->result_id))
{
+ // Most versions of MySQL store timestamp as a string
$is_int[$i] = (in_array(
strtolower(mysql_field_type($query->result_id, $i)),
- array('tinyint', 'smallint', 'mediumint', 'int', 'bigint', 'timestamp'),
+ array('tinyint', 'smallint', 'mediumint', 'int', 'bigint'), //, 'timestamp'),
TRUE)
) ? TRUE : FALSE;
@@ -255,7 +214,39 @@ class CI_DB_mysql_utility extends CI_DB_utility {
return $output;
}
+ /**
+ *
+ * The functions below have been deprecated as of 1.6, and are only here for backwards
+ * compatibility. They now reside in dbforge(). The use of dbutils for database manipulation
+ * is STRONGLY discouraged in favour if using dbforge.
+ *
+ */
-}
+ /**
+ * Create database
+ *
+ * @access private
+ * @param string the database name
+ * @return bool
+ */
+ function _create_database($name)
+ {
+ return "CREATE DATABASE ".$name;
+ }
+ // --------------------------------------------------------------------
+
+ /**
+ * Drop database
+ *
+ * @access private
+ * @param string the database name
+ * @return bool
+ */
+ function _drop_database($name)
+ {
+ return "DROP DATABASE ".$name;
+ }
+
+}
?> \ No newline at end of file
diff --git a/system/database/drivers/mysqli/mysqli_driver.php b/system/database/drivers/mysqli/mysqli_driver.php
index ebed81390..d295ca9f2 100644
--- a/system/database/drivers/mysqli/mysqli_driver.php
+++ b/system/database/drivers/mysqli/mysqli_driver.php
@@ -35,7 +35,7 @@ class CI_DB_mysqli_driver extends CI_DB {
* database engines, so this string appears in each driver and is
* used for the count_all() and count_all_results() functions.
*/
- var $_count_string = "SELECT COUNT(*) AS numrows ";
+ var $_count_string = "SELECT COUNT(*) AS ";
var $_random_keyword = ' RAND()'; // database specific random keyword
/**
@@ -87,6 +87,22 @@ class CI_DB_mysqli_driver extends CI_DB {
// --------------------------------------------------------------------
/**
+ * Set client character set
+ *
+ * @access public
+ * @param string
+ * @param string
+ * @return resource
+ */
+ function db_set_charset($charset, $collation)
+ {
+ // TODO - add support if needed
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
* Version number query string
*
* @access public
@@ -307,15 +323,16 @@ class CI_DB_mysqli_driver extends CI_DB {
* Generates a platform-specific query string so that the table names can be fetched
*
* @access private
+ * @param boolean
* @return string
*/
function _list_tables($prefix_limit = FALSE)
{
$sql = "SHOW TABLES FROM `".$this->database."`";
- if ($prefix_limit !== FALSE AND $this->_stdprefix != '')
+ if ($prefix_limit !== FALSE AND $this->dbprefix != '')
{
- $sql .= " LIKE '".$this->_stdprefix."%'";
+ $sql .= " LIKE '".$this->dbprefix."%'";
}
return $sql;
@@ -404,6 +421,58 @@ class CI_DB_mysqli_driver extends CI_DB {
// --------------------------------------------------------------------
/**
+ * Protect Identifiers
+ *
+ * This function adds backticks if appropriate based on db type
+ *
+ * @access private
+ * @param mixed the item to escape
+ * @param boolean only affect the first word
+ * @return mixed the item with backticks
+ */
+ function _protect_identifiers($item, $first_word_only = FALSE)
+ {
+ if (is_array($item))
+ {
+ $escaped_array = array();
+
+ foreach($item as $k=>$v)
+ {
+ $escaped_array[$this->_protect_identifiers($k)] = $this->_protect_identifiers($v, $first_word_only);
+ }
+
+ return $escaped_array;
+ }
+
+ // This function may get "item1 item2" as a string, and so
+ // we may need "`item1` `item2`" and not "`item1 item2`"
+ if (strpos($item, ' ') !== FALSE)
+ {
+ // This function may get "field >= 1", and need it to return "`field` >= 1"
+ if ($first_word_only === TRUE)
+ {
+ return '`'.preg_replace('/ /', '` ', $item, 1);
+ }
+
+ $item = preg_replace('/(^|\s|\()([\w\d\-\_]+?)(\s|\)|$)/iS', '$1`$2`$3', $item);
+ }
+
+ $exceptions = array('AS', '/', '-', '%', '+', '*');
+
+ foreach ($exceptions as $exception)
+ {
+ if (stristr($item, " `{$exception}` ") !== FALSE)
+ {
+ $item = preg_replace('/ `('.preg_quote($exception).')` /i', ' $1 ', $item);
+ }
+ }
+
+ return $item;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
* Insert statement
*
* Generates a platform-specific insert string from the supplied data
@@ -430,9 +499,11 @@ class CI_DB_mysqli_driver extends CI_DB {
* @param string the table name
* @param array the update data
* @param array the where clause
+ * @param array the orderby clause
+ * @param array the limit clause
* @return string
*/
- function _update($table, $values, $where, $limit = FALSE)
+ function _update($table, $values, $where, $orderby = array(), $limit = FALSE)
{
foreach($values as $key => $val)
{
@@ -440,8 +511,29 @@ class CI_DB_mysqli_driver extends CI_DB {
}
$limit = (!$limit) ? '' : ' LIMIT '.$limit;
+
+ $orderby = (count($orderby) >= 1)?' ORDER BY '.implode(", ", $orderby):'';
- return "UPDATE ".$this->_escape_table($table)." SET ".implode(', ', $valstr)." WHERE ".implode(" ", $where).$limit;
+ return "UPDATE ".$this->_escape_table($table)." SET ".implode(', ', $valstr)." WHERE ".implode(" ", $where).$orderby.$limit;
+ }
+
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Truncate statement
+ *
+ * Generates a platform-specific truncate string from the supplied data
+ * If the database does not support the truncate() command
+ * This function maps to "DELETE FROM table"
+ *
+ * @access public
+ * @param string the table name
+ * @return string
+ */
+ function _truncate($table)
+ {
+ return "TRUNCATE ".$this->_escape_table($table);
}
// --------------------------------------------------------------------
@@ -454,13 +546,28 @@ class CI_DB_mysqli_driver extends CI_DB {
* @access public
* @param string the table name
* @param array the where clause
+ * @param string the limit clause
* @return string
*/
- function _delete($table, $where, $limit = FALSE)
+ function _delete($table, $where = array(), $like = array(), $limit = FALSE)
{
+ $conditions = '';
+
+ if (count($where) > 0 || count($like) > 0)
+ {
+ $conditions = "\nWHERE ";
+ $conditions .= implode("\n", $this->ar_where);
+
+ if (count($where) > 0 && count($like) > 0)
+ {
+ $conditions .= " AND ";
+ }
+ $conditions .= implode("\n", $like);
+ }
+
$limit = (!$limit) ? '' : ' LIMIT '.$limit;
- return "DELETE FROM ".$this->_escape_table($table)." WHERE ".implode(" ", $where).$limit;
+ return "DELETE FROM ".$table.$conditions.$limit;
}
// --------------------------------------------------------------------
diff --git a/system/database/drivers/mysqli/mysqli_forge.php b/system/database/drivers/mysqli/mysqli_forge.php
new file mode 100644
index 000000000..3da5d2c49
--- /dev/null
+++ b/system/database/drivers/mysqli/mysqli_forge.php
@@ -0,0 +1,217 @@
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeigniter.com/user_guide/license.html
+ * @link http://www.codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * MySQLi Forge Class
+ *
+ * @category Database
+ * @author Rick Ellis
+ * @link http://www.codeigniter.com/user_guide/database/
+ */
+class CI_DB_mysqli_forge extends CI_DB_forge {
+
+ /**
+ * Create database
+ *
+ * @access private
+ * @param string the database name
+ * @return bool
+ */
+ function _create_database($name)
+ {
+ return "CREATE DATABASE ".$name;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Drop database
+ *
+ * @access private
+ * @param string the database name
+ * @return bool
+ */
+ function _drop_database($name)
+ {
+ return "DROP DATABASE ".$name;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Drop Table
+ *
+ * @access private
+ * @return bool
+ */
+ function _drop_table($table)
+ {
+ return "DROP TABLE IF EXISTS ".$this->db->_escape_table($table);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Create Table
+ *
+ * @access private
+ * @param string the table name
+ * @param array the fields
+ * @param mixed primary key(s)
+ * @param mixed key(s)
+ * @param boolean should 'IF NOT EXISTS' be added to the SQL
+ * @return bool
+ */
+ function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists)
+ {
+ $sql = 'CREATE TABLE ';
+
+ if ($if_not_exists === TRUE)
+ {
+ $sql .= 'IF NOT EXISTS ';
+ }
+
+ $sql .= $this->db->_escape_table($table)." (";
+ $current_field_count = 0;
+
+ foreach ($fields as $field=>$attributes)
+ {
+ // Numeric field names aren't allowed in databases, so if the key is
+ // numeric, we know it was assigned by PHP and the developer manually
+ // entered the field information, so we'll simply add it to the list
+ if (is_numeric($field))
+ {
+ $sql .= "\n\t$attributes";
+ }
+ else
+ {
+ $attributes = array_change_key_case($attributes, CASE_UPPER);
+
+ $sql .= "\n\t".$this->db->_protect_identifiers($field);
+
+ $sql .= ' '.$attributes['TYPE'];
+
+ if (array_key_exists('CONSTRAINT', $attributes))
+ {
+ $sql .= '('.$attributes['CONSTRAINT'].')';
+ }
+
+ if (array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE)
+ {
+ $sql .= ' UNSIGNED';
+ }
+
+ if (array_key_exists('DEFAULT', $attributes))
+ {
+ $sql .= ' DEFAULT \''.$attributes['DEFAULT'].'\'';
+ }
+
+ if (array_key_exists('NULL', $attributes) && $attributes['NULL'] === TRUE)
+ {
+ $sql .= ' NULL';
+ }
+ else
+ {
+ $sql .= ' NOT NULL';
+ }
+
+ if (array_key_exists('AUTO_INCREMENT', $attributes) && $attributes['AUTO_INCREMENT'] === TRUE)
+ {
+ $sql .= ' AUTO_INCREMENT';
+ }
+ }
+
+ // don't add a comma on the end of the last field
+ if (++$current_field_count < count($fields))
+ {
+ $sql .= ',';
+ }
+ }
+
+ if (count($primary_keys) > 0)
+ {
+ $primary_keys = $this->db->_protect_identifiers($primary_keys);
+ $sql .= ",\n\tPRIMARY KEY (" . implode(', ', $primary_keys) . ")";
+ }
+
+ if (is_array($keys) && count($keys) > 0)
+ {
+ $keys = $this->db->_protect_identifiers($keys);
+ foreach ($keys as $key)
+ {
+ $sql .= ",\n\tKEY ($key)";
+ }
+ }
+
+ $sql .= "\n) DEFAULT CHARACTER SET {$this->db->char_set} COLLATE {$this->db->dbcollat};";
+
+ return $sql;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Alter table query
+ *
+ * Generates a platform-specific query so that a table can be altered
+ * Called by add_column(), drop_column(), and column_alter(),
+ *
+ * @access private
+ * @param string the ALTER type (ADD, DROP, CHANGE)
+ * @param string the column name
+ * @param string the table name
+ * @param string the column definition
+ * @param string the default value
+ * @param boolean should 'NOT NULL' be added
+ * @param string the field after which we should add the new field
+ * @return object
+ */
+ function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '')
+ {
+ $sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table)." $alter_type ".$this->db->_protect_identifiers($column_name);
+
+ // DROP has everything it needs now.
+ if ($alter_type == 'DROP')
+ {
+ return $sql;
+ }
+
+ $sql .= " $column_definition";
+
+ if ($default_value != '')
+ {
+ $sql .= " DEFAULT \"$default_value\"";
+ }
+
+ if ($null === NULL)
+ {
+ $sql .= ' NULL';
+ }
+ else
+ {
+ $sql .= ' NOT NULL';
+ }
+
+ if ($after_field != '')
+ {
+ $sql .= ' AFTER ' . $this->db->_protect_identifiers($after_field);
+ }
+
+ return $sql;
+ }
+}
+?> \ No newline at end of file
diff --git a/system/database/drivers/mysqli/mysqli_utility.php b/system/database/drivers/mysqli/mysqli_utility.php
index c904e92d7..1d910638f 100644
--- a/system/database/drivers/mysqli/mysqli_utility.php
+++ b/system/database/drivers/mysqli/mysqli_utility.php
@@ -25,47 +25,6 @@
class CI_DB_mysqli_utility extends CI_DB_utility {
/**
- * Create database
- *
- * @access private
- * @param string the database name
- * @return bool
- */
- function _create_database($name)
- {
- return "CREATE DATABASE ".$name;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Drop database
- *
- * @access private
- * @param string the database name
- * @return bool
- */
- function _drop_database($name)
- {
- return "DROP DATABASE ".$name;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Drop Table
- *
- * @access private
- * @return bool
- */
- function _drop_table($table)
- {
- return "DROP TABLE IF EXISTS ".$this->db->_escape_table($table);
- }
-
- // --------------------------------------------------------------------
-
- /**
* List databases
*
* @access private
@@ -187,9 +146,10 @@ class CI_DB_mysqli_utility extends CI_DB_utility {
$is_int = array();
while ($field = mysqli_fetch_field($query->result_id))
{
+ // Most versions of MySQL store timestamp as a string
$is_int[$i] = (in_array(
strtolower(mysql_field_type($query->result_id, $i)),
- array('tinyint', 'smallint', 'mediumint', 'int', 'bigint', 'timestamp'),
+ array('tinyint', 'smallint', 'mediumint', 'int', 'bigint'), // 'timestamp'),
TRUE)
) ? TRUE : FALSE;
@@ -255,8 +215,39 @@ class CI_DB_mysqli_utility extends CI_DB_utility {
return $output;
}
+ /**
+ *
+ * The functions below have been deprecated as of 1.6, and are only here for backwards
+ * compatibility. They now reside in dbforge(). The use of dbutils for database manipulation
+ * is STRONGLY discouraged in favour if using dbforge.
+ *
+ */
+
+ /**
+ * Create database
+ *
+ * @access private
+ * @param string the database name
+ * @return bool
+ */
+ function _create_database($name)
+ {
+ return "CREATE DATABASE ".$name;
+ }
+
+ // --------------------------------------------------------------------
+ /**
+ * Drop database
+ *
+ * @access private
+ * @param string the database name
+ * @return bool
+ */
+ function _drop_database($name)
+ {
+ return "DROP DATABASE ".$name;
+ }
}
-
?> \ No newline at end of file
diff --git a/system/database/drivers/oci8/oci8_driver.php b/system/database/drivers/oci8/oci8_driver.php
index c4ab70051..6d3b72261 100644
--- a/system/database/drivers/oci8/oci8_driver.php
+++ b/system/database/drivers/oci8/oci8_driver.php
@@ -48,7 +48,8 @@ class CI_DB_oci8_driver extends CI_DB {
* database engines, so this string appears in each driver and is
* used for the count_all() and count_all_results() functions.
*/
- var $_count_string = "SELECT COUNT(1) AS numrows ";
+ var $_count_string = "SELECT COUNT(1) AS ";
+ var $_random_keyword = ' ASC'; // not currently supported
// Set "auto commit" by default
var $_commit = OCI_COMMIT_ON_SUCCESS;
@@ -101,6 +102,22 @@ class CI_DB_oci8_driver extends CI_DB {
// --------------------------------------------------------------------
/**
+ * Set client character set
+ *
+ * @access public
+ * @param string
+ * @param string
+ * @return resource
+ */
+ function db_set_charset($charset, $collation)
+ {
+ // TODO - add support if needed
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
* Version number query string
*
* @access public
@@ -415,11 +432,19 @@ class CI_DB_oci8_driver extends CI_DB {
* Generates a platform-specific query string so that the table names can be fetched
*
* @access private
+ * @param boolean
* @return string
*/
- function _list_tables()
+ function _list_tables($prefix_limit = FALSE)
{
- return "SELECT TABLE_NAME FROM ALL_TABLES";
+ $sql = "SELECT TABLE_NAME FROM ALL_TABLES";
+
+ if ($prefix_limit !== FALSE AND $this->dbprefix != '')
+ {
+ $sql .= " WHERE TABLE_NAME LIKE '".$this->dbprefix."%'";
+ }
+
+ return $sql;
}
// --------------------------------------------------------------------
@@ -507,6 +532,58 @@ class CI_DB_oci8_driver extends CI_DB {
// --------------------------------------------------------------------
/**
+ * Protect Identifiers
+ *
+ * This function adds backticks if appropriate based on db type
+ *
+ * @access private
+ * @param mixed the item to escape
+ * @param boolean only affect the first word
+ * @return mixed the item with backticks
+ */
+ function _protect_identifiers($item, $first_word_only = FALSE)
+ {
+ if (is_array($item))
+ {
+ $escaped_array = array();
+
+ foreach($item as $k=>$v)
+ {
+ $escaped_array[$this->_protect_identifiers($k)] = $this->_protect_identifiers($v, $first_word_only);
+ }
+
+ return $escaped_array;
+ }
+
+ // This function may get "item1 item2" as a string, and so
+ // we may need "`item1` `item2`" and not "`item1 item2`"
+ if (strpos($item, ' ') !== FALSE)
+ {
+ // This function may get "field >= 1", and need it to return "`field` >= 1"
+ if ($first_word_only === TRUE)
+ {
+ return '`'.preg_replace('/ /', '` ', $item, 1);
+ }
+
+ $item = preg_replace('/(^|\s|\()([\w\d\-\_]+?)(\s|\)|$)/iS', '$1`$2`$3', $item);
+ }
+
+ $exceptions = array('AS', '/', '-', '%', '+', '*');
+
+ foreach ($exceptions as $exception)
+ {
+ if (stristr($item, " `{$exception}` ") !== FALSE)
+ {
+ $item = preg_replace('/ `('.preg_quote($exception).')` /i', ' $1 ', $item);
+ }
+ }
+
+ return $item;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
* Insert statement
*
* Generates a platform-specific insert string from the supplied data
@@ -529,13 +606,15 @@ class CI_DB_oci8_driver extends CI_DB {
*
* Generates a platform-specific update string from the supplied data
*
- * @access public
- * @param string the table name
- * @param array the update data
- * @param array the where clause
- * @return string
+ * @access public
+ * @param string the table name
+ * @param array the update data
+ * @param array the where clause
+ * @param array the orderby clause
+ * @param array the limit clause
+ * @return string
*/
- function _update($table, $values, $where, $limit = FALSE)
+ function _update($table, $values, $where, $orderby = array(), $limit = FALSE)
{
foreach($values as $key => $val)
{
@@ -543,27 +622,62 @@ class CI_DB_oci8_driver extends CI_DB {
}
$limit = (!$limit) ? '' : ' LIMIT '.$limit;
+
+ $orderby = (count($orderby) >= 1)?' ORDER BY '.implode(", ", $orderby):'';
- return "UPDATE ".$this->_escape_table($table)." SET ".implode(', ', $valstr)." WHERE ".implode(" ", $where).$limit;
+ return "UPDATE ".$this->_escape_table($table)." SET ".implode(', ', $valstr)." WHERE ".implode(" ", $where).$orderby.$limit;
}
// --------------------------------------------------------------------
/**
+ * Truncate statement
+ *
+ * Generates a platform-specific truncate string from the supplied data
+ * If the database does not support the truncate() command
+ * This function maps to "DELETE FROM table"
+ *
+ * @access public
+ * @param string the table name
+ * @return string
+ */
+ function _truncate($table)
+ {
+ return "TRUNCATE TABLE ".$this->_escape_table($table);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
* Delete statement
*
* Generates a platform-specific delete string from the supplied data
*
- * @access public
- * @param string the table name
- * @param array the where clause
- * @return string
- */
- function _delete($table, $where, $limit = FALSE)
+ * @access public
+ * @param string the table name
+ * @param array the where clause
+ * @param string the limit clause
+ * @return string
+ */
+ function _delete($table, $where = array(), $like = array(), $limit = FALSE)
{
+ $conditions = '';
+
+ if (count($where) > 0 || count($like) > 0)
+ {
+ $conditions = "\nWHERE ";
+ $conditions .= implode("\n", $this->ar_where);
+
+ if (count($where) > 0 && count($like) > 0)
+ {
+ $conditions .= " AND ";
+ }
+ $conditions .= implode("\n", $like);
+ }
+
$limit = (!$limit) ? '' : ' LIMIT '.$limit;
- return "DELETE FROM ".$this->_escape_table($table)." WHERE ".implode(" ", $where).$limit;
+ return "DELETE FROM ".$table.$conditions.$limit;
}
// --------------------------------------------------------------------
diff --git a/system/database/drivers/oci8/oci8_forge.php b/system/database/drivers/oci8/oci8_forge.php
new file mode 100644
index 000000000..c982e66a3
--- /dev/null
+++ b/system/database/drivers/oci8/oci8_forge.php
@@ -0,0 +1,216 @@
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeigniter.com/user_guide/license.html
+ * @link http://www.codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Oracle Forge Class
+ *
+ * @category Database
+ * @author Rick Ellis
+ * @link http://www.codeigniter.com/user_guide/database/
+ */
+class CI_DB_oci8_forge extends CI_DB_forge {
+
+ /**
+ * Create database
+ *
+ * @access public
+ * @param string the database name
+ * @return bool
+ */
+ function _create_database($name)
+ {
+ return FALSE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Drop database
+ *
+ * @access private
+ * @param string the database name
+ * @return bool
+ */
+ function _drop_database($name)
+ {
+ return FALSE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Create Table
+ *
+ * @access private
+ * @param string the table name
+ * @param array the fields
+ * @param mixed primary key(s)
+ * @param mixed key(s)
+ * @param boolean should 'IF NOT EXISTS' be added to the SQL
+ * @return bool
+ */
+ function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists)
+ {
+ $sql = 'CREATE TABLE ';
+
+ if ($if_not_exists === TRUE)
+ {
+ $sql .= 'IF NOT EXISTS ';
+ }
+
+ $sql .= $this->db->_escape_table($table)." (";
+ $current_field_count = 0;
+
+ foreach ($fields as $field=>$attributes)
+ {
+ // Numeric field names aren't allowed in databases, so if the key is
+ // numeric, we know it was assigned by PHP and the developer manually
+ // entered the field information, so we'll simply add it to the list
+ if (is_numeric($field))
+ {
+ $sql .= "\n\t$attributes";
+ }
+ else
+ {
+ $attributes = array_change_key_case($attributes, CASE_UPPER);
+
+ $sql .= "\n\t".$this->db->_protect_identifiers($field);
+
+ $sql .= ' '.$attributes['TYPE'];
+
+ if (array_key_exists('CONSTRAINT', $attributes))
+ {
+ $sql .= '('.$attributes['CONSTRAINT'].')';
+ }
+
+ if (array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE)
+ {
+ $sql .= ' UNSIGNED';
+ }
+
+ if (array_key_exists('DEFAULT', $attributes))
+ {
+ $sql .= ' DEFAULT \''.$attributes['DEFAULT'].'\'';
+ }
+
+ if (array_key_exists('NULL', $attributes) && $attributes['NULL'] === TRUE)
+ {
+ $sql .= ' NULL';
+ }
+ else
+ {
+ $sql .= ' NOT NULL';
+ }
+
+ if (array_key_exists('AUTO_INCREMENT', $attributes) && $attributes['AUTO_INCREMENT'] === TRUE)
+ {
+ $sql .= ' AUTO_INCREMENT';
+ }
+ }
+
+ // don't add a comma on the end of the last field
+ if (++$current_field_count < count($fields))
+ {
+ $sql .= ',';
+ }
+ }
+
+ if (count($primary_keys) > 0)
+ {
+ $primary_keys = $this->db->_protect_identifiers($primary_keys);
+ $sql .= ",\n\tPRIMARY KEY (" . implode(', ', $primary_keys) . ")";
+ }
+
+ if (count($keys) > 0)
+ {
+ $keys = $this->db->_protect_identifiers($keys);
+ $sql .= ",\n\tUNIQUE COLUMNS (" . implode(', ', $keys) . ")";
+ }
+
+ $sql .= "\n)";
+
+ return $sql;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Drop Table
+ *
+ * @access private
+ * @return bool
+ */
+ function _drop_table($table)
+ {
+ return FALSE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Alter table query
+ *
+ * Generates a platform-specific query so that a table can be altered
+ * Called by add_column(), drop_column(), and column_alter(),
+ *
+ * @access private
+ * @param string the ALTER type (ADD, DROP, CHANGE)
+ * @param string the column name
+ * @param string the table name
+ * @param string the column definition
+ * @param string the default value
+ * @param boolean should 'NOT NULL' be added
+ * @param string the field after which we should add the new field
+ * @return object
+ */
+ function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '')
+ {
+ $sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table)." $alter_type ".$this->db->_protect_identifiers($column_name);
+
+ // DROP has everything it needs now.
+ if ($alter_type == 'DROP')
+ {
+ return $sql;
+ }
+
+ $sql .= " $column_definition";
+
+ if ($default_value != '')
+ {
+ $sql .= " DEFAULT \"$default_value\"";
+ }
+
+ if ($null === NULL)
+ {
+ $sql .= ' NULL';
+ }
+ else
+ {
+ $sql .= ' NOT NULL';
+ }
+
+ if ($after_field != '')
+ {
+ $sql .= ' AFTER ' . $this->db->_protect_identifiers($after_field);
+ }
+
+ return $sql;
+
+ }
+
+}
+?> \ No newline at end of file
diff --git a/system/database/drivers/oci8/oci8_utility.php b/system/database/drivers/oci8/oci8_utility.php
index 0f9e4e838..67296da5b 100644
--- a/system/database/drivers/oci8/oci8_utility.php
+++ b/system/database/drivers/oci8/oci8_utility.php
@@ -24,35 +24,6 @@
*/
class CI_DB_oci8_utility extends CI_DB_utility {
-
- /**
- * Create database
- *
- * @access public
- * @param string the database name
- * @return bool
- */
- function _create_database($name)
- {
- return FALSE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Drop database
- *
- * @access private
- * @param string the database name
- * @return bool
- */
- function _drop_database($name)
- {
- return FALSE;
- }
-
- // --------------------------------------------------------------------
-
/**
* List databases
*
@@ -67,19 +38,6 @@ class CI_DB_oci8_utility extends CI_DB_utility {
// --------------------------------------------------------------------
/**
- * Drop Table
- *
- * @access private
- * @return bool
- */
- function _drop_table($table)
- {
- return FALSE;
- }
-
- // --------------------------------------------------------------------
-
- /**
* Optimize table query
*
* Generates a platform-specific query so that a table can be optimized
@@ -124,6 +82,39 @@ class CI_DB_oci8_utility extends CI_DB_utility {
return $this->db->display_error('db_unsuported_feature');
}
-}
+ /**
+ *
+ * The functions below have been deprecated as of 1.6, and are only here for backwards
+ * compatibility. They now reside in dbforge(). The use of dbutils for database manipulation
+ * is STRONGLY discouraged in favour if using dbforge.
+ *
+ */
+
+ /**
+ * Create database
+ *
+ * @access public
+ * @param string the database name
+ * @return bool
+ */
+ function _create_database($name)
+ {
+ return FALSE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Drop database
+ *
+ * @access private
+ * @param string the database name
+ * @return bool
+ */
+ function _drop_database($name)
+ {
+ return FALSE;
+ }
+}
?> \ No newline at end of file
diff --git a/system/database/drivers/odbc/odbc_driver.php b/system/database/drivers/odbc/odbc_driver.php
index 040ffed9e..0bdfc41d5 100644
--- a/system/database/drivers/odbc/odbc_driver.php
+++ b/system/database/drivers/odbc/odbc_driver.php
@@ -35,8 +35,14 @@ class CI_DB_odbc_driver extends CI_DB {
* database engines, so this string appears in each driver and is
* used for the count_all() and count_all_results() functions.
*/
- var $_count_string = "SELECT COUNT(*) AS numrows ";
- var $_random_keyword = ' RND('.time().')'; // database specific random keyword
+ var $_count_string = "SELECT COUNT(*) AS ";
+ var $_random_keyword;
+
+
+ function CI_DB_odbc_driver()
+ {
+ $_random_keyword = ' RND('.time().')'; // database specific random keyword
+ }
/**
* Non-persistent database connection
@@ -79,6 +85,22 @@ class CI_DB_odbc_driver extends CI_DB {
// --------------------------------------------------------------------
/**
+ * Set client character set
+ *
+ * @access public
+ * @param string
+ * @param string
+ * @return resource
+ */
+ function db_set_charset($charset, $collation)
+ {
+ // TODO - add support if needed
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
* Version number query string
*
* @access public
@@ -276,11 +298,20 @@ class CI_DB_odbc_driver extends CI_DB {
* Generates a platform-specific query string so that the table names can be fetched
*
* @access private
+ * @param boolean
* @return string
*/
- function _list_tables()
+ function _list_tables($prefix_limit = FALSE)
{
- return "SHOW TABLES FROM `".$this->database."`";
+ $sql = "SHOW TABLES FROM `".$this->database."`";
+
+ if ($prefix_limit !== FALSE AND $this->dbprefix != '')
+ {
+ //$sql .= " LIKE '".$this->dbprefix."%'";
+ return FALSE; // not currently supported
+ }
+
+ return $sql;
}
// --------------------------------------------------------------------
@@ -366,6 +397,58 @@ class CI_DB_odbc_driver extends CI_DB {
// --------------------------------------------------------------------
/**
+ * Protect Identifiers
+ *
+ * This function adds backticks if appropriate based on db type
+ *
+ * @access private
+ * @param mixed the item to escape
+ * @param boolean only affect the first word
+ * @return mixed the item with backticks
+ */
+ function _protect_identifiers($item, $first_word_only = FALSE)
+ {
+ if (is_array($item))
+ {
+ $escaped_array = array();
+
+ foreach($item as $k=>$v)
+ {
+ $escaped_array[$this->_protect_identifiers($k)] = $this->_protect_identifiers($v, $first_word_only);
+ }
+
+ return $escaped_array;
+ }
+
+ // This function may get "item1 item2" as a string, and so
+ // we may need "`item1` `item2`" and not "`item1 item2`"
+ if (strpos($item, ' ') !== FALSE)
+ {
+ // This function may get "field >= 1", and need it to return "`field` >= 1"
+ if ($first_word_only === TRUE)
+ {
+ return '`'.preg_replace('/ /', '` ', $item, 1);
+ }
+
+ $item = preg_replace('/(^|\s|\()([\w\d\-\_]+?)(\s|\)|$)/iS', '$1`$2`$3', $item);
+ }
+
+ $exceptions = array('AS', '/', '-', '%', '+', '*');
+
+ foreach ($exceptions as $exception)
+ {
+ if (stristr($item, " `{$exception}` ") !== FALSE)
+ {
+ $item = preg_replace('/ `('.preg_quote($exception).')` /i', ' $1 ', $item);
+ }
+ }
+
+ return $item;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
* Insert statement
*
* Generates a platform-specific insert string from the supplied data
@@ -392,9 +475,11 @@ class CI_DB_odbc_driver extends CI_DB {
* @param string the table name
* @param array the update data
* @param array the where clause
+ * @param array the orderby clause
+ * @param array the limit clause
* @return string
*/
- function _update($table, $values, $where, $limit = FALSE)
+ function _update($table, $values, $where, $orderby = array(), $limit = FALSE)
{
foreach($values as $key => $val)
{
@@ -402,8 +487,29 @@ class CI_DB_odbc_driver extends CI_DB {
}
$limit = (!$limit) ? '' : ' LIMIT '.$limit;
+
+ $orderby = (count($orderby) >= 1)?' ORDER BY '.implode(", ", $orderby):'';
+
+ return "UPDATE ".$this->_escape_table($table)." SET ".implode(', ', $valstr)." WHERE ".implode(" ", $where).$orderby.$limit;
+ }
+
- return "UPDATE ".$this->_escape_table($table)." SET ".implode(', ', $valstr)." WHERE ".implode(" ", $where).$limit;
+ // --------------------------------------------------------------------
+
+ /**
+ * Truncate statement
+ *
+ * Generates a platform-specific truncate string from the supplied data
+ * If the database does not support the truncate() command
+ * This function maps to "DELETE FROM table"
+ *
+ * @access public
+ * @param string the table name
+ * @return string
+ */
+ function _truncate($table)
+ {
+ return $this->_delete($table);
}
// --------------------------------------------------------------------
@@ -416,13 +522,28 @@ class CI_DB_odbc_driver extends CI_DB {
* @access public
* @param string the table name
* @param array the where clause
+ * @param string the limit clause
* @return string
*/
- function _delete($table, $where, $limit = FALSE)
+ function _delete($table, $where = array(), $like = array(), $limit = FALSE)
{
+ $conditions = '';
+
+ if (count($where) > 0 || count($like) > 0)
+ {
+ $conditions = "\nWHERE ";
+ $conditions .= implode("\n", $this->ar_where);
+
+ if (count($where) > 0 && count($like) > 0)
+ {
+ $conditions .= " AND ";
+ }
+ $conditions .= implode("\n", $like);
+ }
+
$limit = (!$limit) ? '' : ' LIMIT '.$limit;
- return "DELETE FROM ".$this->_escape_table($table)." WHERE ".implode(" ", $where).$limit;
+ return "DELETE FROM ".$table.$conditions.$limit;
}
// --------------------------------------------------------------------
diff --git a/system/database/drivers/odbc/odbc_forge.php b/system/database/drivers/odbc/odbc_forge.php
new file mode 100644
index 000000000..1d79344c1
--- /dev/null
+++ b/system/database/drivers/odbc/odbc_forge.php
@@ -0,0 +1,236 @@
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeigniter.com/user_guide/license.html
+ * @link http://www.codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * ODBC Forge Class
+ *
+ * @category Database
+ * @author Rick Ellis
+ * @link http://www.codeigniter.com/database/
+ */
+class CI_DB_odbc_forge extends CI_DB_forge {
+
+ /**
+ * Create database
+ *
+ * @access private
+ * @param string the database name
+ * @return bool
+ */
+ function _create_database()
+ {
+ // ODBC has no "create database" command since it's
+ // designed to connect to an existing database
+ if ($this->db->db_debug)
+ {
+ return $this->db->display_error('db_unsuported_feature');
+ }
+ return FALSE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Drop database
+ *
+ * @access private
+ * @param string the database name
+ * @return bool
+ */
+ function _drop_database($name)
+ {
+ // ODBC has no "drop database" command since it's
+ // designed to connect to an existing database
+ if ($this->db->db_debug)
+ {
+ return $this->db->display_error('db_unsuported_feature');
+ }
+ return FALSE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Create Table
+ *
+ * @access private
+ * @param string the table name
+ * @param array the fields
+ * @param mixed primary key(s)
+ * @param mixed key(s)
+ * @param boolean should 'IF NOT EXISTS' be added to the SQL
+ * @return bool
+ */
+ function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists)
+ {
+ $sql = 'CREATE TABLE ';
+
+ if ($if_not_exists === TRUE)
+ {
+ $sql .= 'IF NOT EXISTS ';
+ }
+
+ $sql .= $this->db->_escape_table($table)." (";
+ $current_field_count = 0;
+
+ foreach ($fields as $field=>$attributes)
+ {
+ // Numeric field names aren't allowed in databases, so if the key is
+ // numeric, we know it was assigned by PHP and the developer manually
+ // entered the field information, so we'll simply add it to the list
+ if (is_numeric($field))
+ {
+ $sql .= "\n\t$attributes";
+ }
+ else
+ {
+ $attributes = array_change_key_case($attributes, CASE_UPPER);
+
+ $sql .= "\n\t".$this->db->_protect_identifiers($field);
+
+ $sql .= ' '.$attributes['TYPE'];
+
+ if (array_key_exists('CONSTRAINT', $attributes))
+ {
+ $sql .= '('.$attributes['CONSTRAINT'].')';
+ }
+
+ if (array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE)
+ {
+ $sql .= ' UNSIGNED';
+ }
+
+ if (array_key_exists('DEFAULT', $attributes))
+ {
+ $sql .= ' DEFAULT \''.$attributes['DEFAULT'].'\'';
+ }
+
+ if (array_key_exists('NULL', $attributes) && $attributes['NULL'] === TRUE)
+ {
+ $sql .= ' NULL';
+ }
+ else
+ {
+ $sql .= ' NOT NULL';
+ }
+
+ if (array_key_exists('AUTO_INCREMENT', $attributes) && $attributes['AUTO_INCREMENT'] === TRUE)
+ {
+ $sql .= ' AUTO_INCREMENT';
+ }
+ }
+
+ // don't add a comma on the end of the last field
+ if (++$current_field_count < count($fields))
+ {
+ $sql .= ',';
+ }
+ }
+
+ if (count($primary_keys) > 0)
+ {
+ $primary_keys = $this->db->_protect_identifiers($primary_keys);
+ $sql .= ",\n\tPRIMARY KEY (" . implode(', ', $primary_keys) . ")";
+ }
+
+ if (is_array($keys) && count($keys) > 0)
+ {
+ $keys = $this->db->_protect_identifiers($keys);
+ foreach ($keys as $key)
+ {
+ $sql .= ",\n\tFOREIGN KEY ($key)";
+ }
+ }
+
+ $sql .= "\n)";
+
+ return $sql;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Drop Table
+ *
+ * @access private
+ * @return bool
+ */
+ function _drop_table($table)
+ {
+ // Not a supported ODBC feature
+ if ($this->db->db_debug)
+ {
+ return $this->db->display_error('db_unsuported_feature');
+ }
+ return FALSE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Alter table query
+ *
+ * Generates a platform-specific query so that a table can be altered
+ * Called by add_column(), drop_column(), and column_alter(),
+ *
+ * @access private
+ * @param string the ALTER type (ADD, DROP, CHANGE)
+ * @param string the column name
+ * @param string the table name
+ * @param string the column definition
+ * @param string the default value
+ * @param boolean should 'NOT NULL' be added
+ * @param string the field after which we should add the new field
+ * @return object
+ */
+ function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '')
+ {
+ $sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table)." $alter_type ".$this->db->_protect_identifiers($column_name);
+
+ // DROP has everything it needs now.
+ if ($alter_type == 'DROP')
+ {
+ return $sql;
+ }
+
+ $sql .= " $column_definition";
+
+ if ($default_value != '')
+ {
+ $sql .= " DEFAULT \"$default_value\"";
+ }
+
+ if ($null === NULL)
+ {
+ $sql .= ' NULL';
+ }
+ else
+ {
+ $sql .= ' NOT NULL';
+ }
+
+ if ($after_field != '')
+ {
+ $sql .= ' AFTER ' . $this->db->_protect_identifiers($after_field);
+ }
+
+ return $sql;
+
+ }
+
+}
+?> \ No newline at end of file
diff --git a/system/database/drivers/odbc/odbc_result.php b/system/database/drivers/odbc/odbc_result.php
index e909fd743..53c317356 100644
--- a/system/database/drivers/odbc/odbc_result.php
+++ b/system/database/drivers/odbc/odbc_result.php
@@ -192,7 +192,6 @@ class CI_DB_odbc_result extends CI_DB_result {
* @access private
* @return object
*/
-
function _odbc_fetch_object(& $odbc_result) {
$rs = array();
$rs_obj = false;
@@ -215,7 +214,6 @@ class CI_DB_odbc_result extends CI_DB_result {
* @access private
* @return array
*/
-
function _odbc_fetch_array(& $odbc_result) {
$rs = array();
$rs_assoc = false;
diff --git a/system/database/drivers/odbc/odbc_utility.php b/system/database/drivers/odbc/odbc_utility.php
index 97e950fc1..d64d15af5 100644
--- a/system/database/drivers/odbc/odbc_utility.php
+++ b/system/database/drivers/odbc/odbc_utility.php
@@ -24,18 +24,15 @@
*/
class CI_DB_odbc_utility extends CI_DB_utility {
-
/**
- * Create database
+ * List databases
*
* @access private
- * @param string the database name
* @return bool
*/
- function _create_database()
+ function _list_databases()
{
- // ODBC has no "create database" command since it's
- // designed to connect to an existing database
+ // Not sure if ODBC lets you list all databases...
if ($this->db->db_debug)
{
return $this->db->display_error('db_unsuported_feature');
@@ -46,16 +43,17 @@ class CI_DB_odbc_utility extends CI_DB_utility {
// --------------------------------------------------------------------
/**
- * Drop database
+ * Optimize table query
+ *
+ * Generates a platform-specific query so that a table can be optimized
*
* @access private
- * @param string the database name
- * @return bool
+ * @param string the table name
+ * @return object
*/
- function _drop_database($name)
+ function _optimize_table($table)
{
- // ODBC has no "drop database" command since it's
- // designed to connect to an existing database
+ // Not a supported ODBC feature
if ($this->db->db_debug)
{
return $this->db->display_error('db_unsuported_feature');
@@ -66,14 +64,17 @@ class CI_DB_odbc_utility extends CI_DB_utility {
// --------------------------------------------------------------------
/**
- * List databases
+ * Repair table query
+ *
+ * Generates a platform-specific query so that a table can be repaired
*
* @access private
- * @return bool
+ * @param string the table name
+ * @return object
*/
- function _list_databases()
+ function _repair_table($table)
{
- // Not sure if ODBC lets you list all databases...
+ // Not a supported ODBC feature
if ($this->db->db_debug)
{
return $this->db->display_error('db_unsuported_feature');
@@ -84,35 +85,37 @@ class CI_DB_odbc_utility extends CI_DB_utility {
// --------------------------------------------------------------------
/**
- * Drop Table
+ * ODBC Export
*
* @access private
- * @return bool
+ * @param array Preferences
+ * @return mixed
*/
- function _drop_table($table)
+ function _backup($params = array())
{
- // Not a supported ODBC feature
- if ($this->db->db_debug)
- {
- return $this->db->display_error('db_unsuported_feature');
- }
- return FALSE;
+ // Currently unsupported
+ return $this->db->display_error('db_unsuported_feature');
}
-
- // --------------------------------------------------------------------
-
+
/**
- * Optimize table query
*
- * Generates a platform-specific query so that a table can be optimized
+ * The functions below have been deprecated as of 1.6, and are only here for backwards
+ * compatibility. They now reside in dbforge(). The use of dbutils for database manipulation
+ * is STRONGLY discouraged in favour if using dbforge.
+ *
+ */
+
+ /**
+ * Create database
*
* @access private
- * @param string the table name
- * @return object
+ * @param string the database name
+ * @return bool
*/
- function _optimize_table($table)
+ function _create_database()
{
- // Not a supported ODBC feature
+ // ODBC has no "create database" command since it's
+ // designed to connect to an existing database
if ($this->db->db_debug)
{
return $this->db->display_error('db_unsuported_feature');
@@ -123,39 +126,21 @@ class CI_DB_odbc_utility extends CI_DB_utility {
// --------------------------------------------------------------------
/**
- * Repair table query
- *
- * Generates a platform-specific query so that a table can be repaired
+ * Drop database
*
* @access private
- * @param string the table name
- * @return object
+ * @param string the database name
+ * @return bool
*/
- function _repair_table($table)
+ function _drop_database($name)
{
- // Not a supported ODBC feature
+ // ODBC has no "drop database" command since it's
+ // designed to connect to an existing database
if ($this->db->db_debug)
{
return $this->db->display_error('db_unsuported_feature');
}
return FALSE;
}
-
- // --------------------------------------------------------------------
-
- /**
- * ODBC Export
- *
- * @access private
- * @param array Preferences
- * @return mixed
- */
- function _backup($params = array())
- {
- // Currently unsupported
- return $this->db->display_error('db_unsuported_feature');
- }
-
}
-
?> \ No newline at end of file
diff --git a/system/database/drivers/postgre/postgre_driver.php b/system/database/drivers/postgre/postgre_driver.php
index 88f08b2d7..63a72f5d3 100644
--- a/system/database/drivers/postgre/postgre_driver.php
+++ b/system/database/drivers/postgre/postgre_driver.php
@@ -35,7 +35,7 @@ class CI_DB_postgre_driver extends CI_DB {
* database engines, so this string appears in each driver and is
* used for the count_all() and count_all_results() functions.
*/
- var $_count_string = "SELECT COUNT(*) AS numrows ";
+ var $_count_string = "SELECT COUNT(*) AS ";
var $_random_keyword = ' RANDOM()'; // database specific random keyword
/**
@@ -83,6 +83,22 @@ class CI_DB_postgre_driver extends CI_DB {
// --------------------------------------------------------------------
/**
+ * Set client character set
+ *
+ * @access public
+ * @param string
+ * @param string
+ * @return resource
+ */
+ function db_set_charset($charset, $collation)
+ {
+ // TODO - add support if needed
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
* Version number query string
*
* @access public
@@ -305,11 +321,19 @@ class CI_DB_postgre_driver extends CI_DB {
* Generates a platform-specific query string so that the table names can be fetched
*
* @access private
+ * @param boolean
* @return string
*/
- function _list_tables()
+ function _list_tables($prefix_limit = FALSE)
{
- return "SELECT table_name FROM information_schema.tables WHERE table_schema = 'public'";
+ $sql = "SELECT table_name FROM information_schema.tables WHERE table_schema = 'public'";
+
+ if ($prefix_limit !== FALSE AND $this->dbprefix != '')
+ {
+ $sql .= " AND table_name LIKE '".$this->dbprefix."%'";
+ }
+
+ return $sql;
}
// --------------------------------------------------------------------
@@ -395,6 +419,58 @@ class CI_DB_postgre_driver extends CI_DB {
// --------------------------------------------------------------------
/**
+ * Protect Identifiers
+ *
+ * This function adds backticks if appropriate based on db type
+ *
+ * @access private
+ * @param mixed the item to escape
+ * @param boolean only affect the first word
+ * @return mixed the item with backticks
+ */
+ function _protect_identifiers($item, $first_word_only = FALSE)
+ {
+ if (is_array($item))
+ {
+ $escaped_array = array();
+
+ foreach($item as $k=>$v)
+ {
+ $escaped_array[$this->_protect_identifiers($k)] = $this->_protect_identifiers($v, $first_word_only);
+ }
+
+ return $escaped_array;
+ }
+
+ // This function may get "item1 item2" as a string, and so
+ // we may need ""item1" "item2"" and not ""item1 item2""
+ if (strpos($item, ' ') !== FALSE)
+ {
+ // This function may get "field >= 1", and need it to return ""field" >= 1"
+ if ($first_word_only === TRUE)
+ {
+ return '"'.preg_replace('/ /', '" ', $item, 1);
+ }
+
+ $item = preg_replace('/(^|\s|\()([\w\d\-\_]+?)(\s|\)|$)/iS', '$1"$2"$3', $item);
+ }
+
+ $exceptions = array('AS', '/', '-', '%', '+', '*');
+
+ foreach ($exceptions as $exception)
+ {
+ if (stristr($item, " "{$exception}" ") !== FALSE)
+ {
+ $item = preg_replace('/ "('.preg_quote($exception).')" /i', ' $1 ', $item);
+ }
+ }
+
+ return $item;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
* Insert statement
*
* Generates a platform-specific insert string from the supplied data
@@ -421,9 +497,11 @@ class CI_DB_postgre_driver extends CI_DB {
* @param string the table name
* @param array the update data
* @param array the where clause
+ * @param array the orderby clause
+ * @param array the limit clause
* @return string
*/
- function _update($table, $values, $where, $limit = FALSE)
+ function _update($table, $values, $where, $orderby = array(), $limit = FALSE)
{
foreach($values as $key => $val)
{
@@ -431,8 +509,29 @@ class CI_DB_postgre_driver extends CI_DB {
}
$limit = (!$limit) ? '' : ' LIMIT '.$limit;
+
+ $orderby = (count($orderby) >= 1)?' ORDER BY '.implode(", ", $orderby):'';
- return "UPDATE ".$this->_escape_table($table)." SET ".implode(', ', $valstr)." WHERE ".implode(" ", $where).$limit;
+ return "UPDATE ".$this->_escape_table($table)." SET ".implode(', ', $valstr)." WHERE ".implode(" ", $where).$orderby.$limit;
+ }
+
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Truncate statement
+ *
+ * Generates a platform-specific truncate string from the supplied data
+ * If the database does not support the truncate() command
+ * This function maps to "DELETE FROM table"
+ *
+ * @access public
+ * @param string the table name
+ * @return string
+ */
+ function _truncate($table)
+ {
+ return "TRUNCATE ".$this->_escape_table($table);
}
// --------------------------------------------------------------------
@@ -445,17 +544,31 @@ class CI_DB_postgre_driver extends CI_DB {
* @access public
* @param string the table name
* @param array the where clause
+ * @param string the limit clause
* @return string
*/
- function _delete($table, $where, $limit = FALSE)
+ function _delete($table, $where = array(), $like = array(), $limit = FALSE)
{
+ $conditions = '';
+
+ if (count($where) > 0 || count($like) > 0)
+ {
+ $conditions = "\nWHERE ";
+ $conditions .= implode("\n", $this->ar_where);
+
+ if (count($where) > 0 && count($like) > 0)
+ {
+ $conditions .= " AND ";
+ }
+ $conditions .= implode("\n", $like);
+ }
+
$limit = (!$limit) ? '' : ' LIMIT '.$limit;
- return "DELETE FROM ".$this->_escape_table($table)." WHERE ".implode(" ", $where).$limit;
+ return "DELETE FROM ".$table.$conditions.$limit;
}
// --------------------------------------------------------------------
-
/**
* Limit string
*
diff --git a/system/database/drivers/postgre/postgre_forge.php b/system/database/drivers/postgre/postgre_forge.php
new file mode 100644
index 000000000..34bbe88b6
--- /dev/null
+++ b/system/database/drivers/postgre/postgre_forge.php
@@ -0,0 +1,219 @@
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeigniter.com/user_guide/license.html
+ * @link http://www.codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Postgre Forge Class
+ *
+ * @category Database
+ * @author Rick Ellis
+ * @link http://www.codeigniter.com/user_guide/database/
+ */
+class CI_DB_postgre_forge extends CI_DB_forge {
+
+ /**
+ * Create database
+ *
+ * @access private
+ * @param string the database name
+ * @return bool
+ */
+ function _create_database($name)
+ {
+ return "CREATE DATABASE ".$name;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Drop database
+ *
+ * @access private
+ * @param string the database name
+ * @return bool
+ */
+ function _drop_database($name)
+ {
+ return "DROP DATABASE ".$name;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Create Table
+ *
+ * @access private
+ * @param string the table name
+ * @param array the fields
+ * @param mixed primary key(s)
+ * @param mixed key(s)
+ * @param boolean should 'IF NOT EXISTS' be added to the SQL
+ * @return bool
+ */
+ function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists)
+ {
+ $sql = 'CREATE TABLE ';
+
+ if ($if_not_exists === TRUE)
+ {
+ $sql .= 'IF NOT EXISTS ';
+ }
+
+ $sql .= $this->db->_escape_table($table)." (";
+ $current_field_count = 0;
+
+ foreach ($fields as $field=>$attributes)
+ {
+ // Numeric field names aren't allowed in databases, so if the key is
+ // numeric, we know it was assigned by PHP and the developer manually
+ // entered the field information, so we'll simply add it to the list
+ if (is_numeric($field))
+ {
+ $sql .= "\n\t$attributes";
+ }
+ else
+ {
+ $attributes = array_change_key_case($attributes, CASE_UPPER);
+
+ $sql .= "\n\t".$this->db->_protect_identifiers($field);
+
+ $sql .= ' '.$attributes['TYPE'];
+
+ if (array_key_exists('CONSTRAINT', $attributes))
+ {
+ $sql .= '('.$attributes['CONSTRAINT'].')';
+ }
+
+ if (array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE)
+ {
+ $sql .= ' UNSIGNED';
+ }
+
+ if (array_key_exists('DEFAULT', $attributes))
+ {
+ $sql .= ' DEFAULT \''.$attributes['DEFAULT'].'\'';
+ }
+
+ if (array_key_exists('NULL', $attributes) && $attributes['NULL'] === TRUE)
+ {
+ $sql .= ' NULL';
+ }
+ else
+ {
+ $sql .= ' NOT NULL';
+ }
+
+ if (array_key_exists('AUTO_INCREMENT', $attributes) && $attributes['AUTO_INCREMENT'] === TRUE)
+ {
+ $sql .= ' AUTO_INCREMENT';
+ }
+ }
+
+ // don't add a comma on the end of the last field
+ if (++$current_field_count < count($fields))
+ {
+ $sql .= ',';
+ }
+ }
+
+ if (count($primary_keys) > 0)
+ {
+ $primary_keys = $this->db->_protect_identifiers($primary_keys);
+ $sql .= ",\n\tPRIMARY KEY (" . implode(', ', $primary_keys) . ")";
+ }
+
+ if (is_array($keys) && count($keys) > 0)
+ {
+ $keys = $this->db->_protect_identifiers($keys);
+ foreach ($keys as $key)
+ {
+ $sql .= ",\n\tFOREIGN KEY ($key)";
+ }
+ }
+
+ $sql .= "\n);";
+
+ return $sql;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Drop Table
+ *
+ * @access private
+ * @return bool
+ */
+ function _drop_table($table)
+ {
+ return "DROP TABLE ".$this->db->_escape_table($table)." CASCADE";
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Alter table query
+ *
+ * Generates a platform-specific query so that a table can be altered
+ * Called by add_column(), drop_column(), and column_alter(),
+ *
+ * @access private
+ * @param string the ALTER type (ADD, DROP, CHANGE)
+ * @param string the column name
+ * @param string the table name
+ * @param string the column definition
+ * @param string the default value
+ * @param boolean should 'NOT NULL' be added
+ * @param string the field after which we should add the new field
+ * @return object
+ */
+ function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '')
+ {
+ $sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table)." $alter_type ".$this->db->_protect_identifiers($column_name);
+
+ // DROP has everything it needs now.
+ if ($alter_type == 'DROP')
+ {
+ return $sql;
+ }
+
+ $sql .= " $column_definition";
+
+ if ($default_value != '')
+ {
+ $sql .= " DEFAULT \"$default_value\"";
+ }
+
+ if ($null === NULL)
+ {
+ $sql .= ' NULL';
+ }
+ else
+ {
+ $sql .= ' NOT NULL';
+ }
+
+ if ($after_field != '')
+ {
+ $sql .= ' AFTER ' . $this->db->_protect_identifiers($after_field);
+ }
+
+ return $sql;
+
+ }
+
+}
+?> \ No newline at end of file
diff --git a/system/database/drivers/postgre/postgre_utility.php b/system/database/drivers/postgre/postgre_utility.php
index fa5960e58..a706d9505 100644
--- a/system/database/drivers/postgre/postgre_utility.php
+++ b/system/database/drivers/postgre/postgre_utility.php
@@ -24,35 +24,6 @@
*/
class CI_DB_postgre_utility extends CI_DB_utility {
-
- /**
- * Create database
- *
- * @access private
- * @param string the database name
- * @return bool
- */
- function _create_database($name)
- {
- return "CREATE DATABASE ".$name;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Drop database
- *
- * @access private
- * @param string the database name
- * @return bool
- */
- function _drop_database($name)
- {
- return "DROP DATABASE ".$name;
- }
-
- // --------------------------------------------------------------------
-
/**
* List databases
*
@@ -67,19 +38,6 @@ class CI_DB_postgre_utility extends CI_DB_utility {
// --------------------------------------------------------------------
/**
- * Drop Table
- *
- * @access private
- * @return bool
- */
- function _drop_table($table)
- {
- return "DROP TABLE ".$this->db->_escape_table($table)." CASCADE";
- }
-
- // --------------------------------------------------------------------
-
- /**
* Optimize table query
*
* Is table optimization supported in Postgre?
@@ -124,6 +82,41 @@ class CI_DB_postgre_utility extends CI_DB_utility {
return $this->db->display_error('db_unsuported_feature');
}
+ /**
+ *
+ * The functions below have been deprecated as of 1.6, and are only here for backwards
+ * compatibility. They now reside in dbforge(). The use of dbutils for database manipulation
+ * is STRONGLY discouraged in favour if using dbforge.
+ *
+ */
+
+ /**
+ * Create database
+ *
+ * @access private
+ * @param string the database name
+ * @return bool
+ */
+ function _create_database($name)
+ {
+ return "CREATE DATABASE ".$name;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Drop database
+ *
+ * @access private
+ * @param string the database name
+ * @return bool
+ */
+ function _drop_database($name)
+ {
+ return "DROP DATABASE ".$name;
+ }
+
+
}
?> \ No newline at end of file
diff --git a/system/database/drivers/sqlite/sqlite_driver.php b/system/database/drivers/sqlite/sqlite_driver.php
index 6189b1ff0..2d0ca157c 100644
--- a/system/database/drivers/sqlite/sqlite_driver.php
+++ b/system/database/drivers/sqlite/sqlite_driver.php
@@ -37,7 +37,7 @@ class CI_DB_sqlite_driver extends CI_DB {
* database engines, so this string appears in each driver and is
* used for the count_all() and count_all_results() functions.
*/
- var $_count_string = "SELECT COUNT(*) AS numrows ";
+ var $_count_string = "SELECT COUNT(*) AS ";
var $_random_keyword = ' Random()'; // database specific random keyword
/**
@@ -104,6 +104,22 @@ class CI_DB_sqlite_driver extends CI_DB {
// --------------------------------------------------------------------
/**
+ * Set client character set
+ *
+ * @access public
+ * @param string
+ * @param string
+ * @return resource
+ */
+ function db_set_charset($charset, $collation)
+ {
+ // TODO - add support if needed
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
* Version number query string
*
* @access public
@@ -299,11 +315,18 @@ class CI_DB_sqlite_driver extends CI_DB {
* Generates a platform-specific query string so that the table names can be fetched
*
* @access private
+ * @param boolean
* @return string
*/
- function _list_tables()
+ function _list_tables($prefix_limit = FALSE)
{
- return "SELECT name from sqlite_master WHERE type='table'";
+ $sql = "SELECT name from sqlite_master WHERE type='table'";
+
+ if ($prefix_limit !== FALSE AND $this->dbprefix != '')
+ {
+ $sql .= " AND 'name' LIKE '".$this->dbprefix."%'";
+ }
+ return $sql;
}
// --------------------------------------------------------------------
@@ -390,6 +413,58 @@ class CI_DB_sqlite_driver extends CI_DB {
// --------------------------------------------------------------------
/**
+ * Protect Identifiers
+ *
+ * This function adds backticks if appropriate based on db type
+ *
+ * @access private
+ * @param mixed the item to escape
+ * @param boolean only affect the first word
+ * @return mixed the item with backticks
+ */
+ function _protect_identifiers($item, $first_word_only = FALSE)
+ {
+ if (is_array($item))
+ {
+ $escaped_array = array();
+
+ foreach($item as $k=>$v)
+ {
+ $escaped_array[$this->_protect_identifiers($k)] = $this->_protect_identifiers($v, $first_word_only);
+ }
+
+ return $escaped_array;
+ }
+
+ // This function may get "item1 item2" as a string, and so
+ // we may need "`item1` `item2`" and not "`item1 item2`"
+ if (strpos($item, ' ') !== FALSE)
+ {
+ // This function may get "field >= 1", and need it to return "`field` >= 1"
+ if ($first_word_only === TRUE)
+ {
+ return '`'.preg_replace('/ /', '` ', $item, 1);
+ }
+
+ $item = preg_replace('/(^|\s|\()([\w\d\-\_]+?)(\s|\)|$)/iS', '$1`$2`$3', $item);
+ }
+
+ $exceptions = array('AS', '/', '-', '%', '+', '*');
+
+ foreach ($exceptions as $exception)
+ {
+ if (stristr($item, " `{$exception}` ") !== FALSE)
+ {
+ $item = preg_replace('/ `('.preg_quote($exception).')` /i', ' $1 ', $item);
+ }
+ }
+
+ return $item;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
* Insert statement
*
* Generates a platform-specific insert string from the supplied data
@@ -416,9 +491,11 @@ class CI_DB_sqlite_driver extends CI_DB {
* @param string the table name
* @param array the update data
* @param array the where clause
+ * @param array the orderby clause
+ * @param array the limit clause
* @return string
*/
- function _update($table, $values, $where, $limit = FALSE)
+ function _update($table, $values, $where, $orderby = array(), $limit = FALSE)
{
foreach($values as $key => $val)
{
@@ -426,8 +503,29 @@ class CI_DB_sqlite_driver extends CI_DB {
}
$limit = (!$limit) ? '' : ' LIMIT '.$limit;
+
+ $orderby = (count($orderby) >= 1)?' ORDER BY '.implode(", ", $orderby):'';
+
+ return "UPDATE ".$this->_escape_table($table)." SET ".implode(', ', $valstr)." WHERE ".implode(" ", $where).$orderby.$limit;
+ }
+
- return "UPDATE ".$this->_escape_table($table)." SET ".implode(', ', $valstr)." WHERE ".implode(" ", $where).$limit;
+ // --------------------------------------------------------------------
+
+ /**
+ * Truncate statement
+ *
+ * Generates a platform-specific truncate string from the supplied data
+ * If the database does not support the truncate() command
+ * This function maps to "DELETE FROM table"
+ *
+ * @access public
+ * @param string the table name
+ * @return string
+ */
+ function _truncate($table)
+ {
+ return $this->_delete($table);
}
// --------------------------------------------------------------------
@@ -440,15 +538,30 @@ class CI_DB_sqlite_driver extends CI_DB {
* @access public
* @param string the table name
* @param array the where clause
+ * @param string the limit clause
* @return string
*/
- function _delete($table, $where, $limit = FALSE)
+ function _delete($table, $where = array(), $like = array(), $limit = FALSE)
{
+ $conditions = '';
+
+ if (count($where) > 0 || count($like) > 0)
+ {
+ $conditions = "\nWHERE ";
+ $conditions .= implode("\n", $this->ar_where);
+
+ if (count($where) > 0 && count($like) > 0)
+ {
+ $conditions .= " AND ";
+ }
+ $conditions .= implode("\n", $like);
+ }
+
$limit = (!$limit) ? '' : ' LIMIT '.$limit;
- return "DELETE FROM ".$this->_escape_table($table)." WHERE ".implode(" ", $where).$limit;
+ return "DELETE FROM ".$table.$conditions.$limit;
}
-
+
// --------------------------------------------------------------------
/**
diff --git a/system/database/drivers/sqlite/sqlite_forge.php b/system/database/drivers/sqlite/sqlite_forge.php
new file mode 100644
index 000000000..54b65987d
--- /dev/null
+++ b/system/database/drivers/sqlite/sqlite_forge.php
@@ -0,0 +1,233 @@
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeigniter.com/user_guide/license.html
+ * @link http://www.codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * SQLite Forge Class
+ *
+ * @category Database
+ * @author Rick Ellis
+ * @link http://www.codeigniter.com/user_guide/database/
+ */
+class CI_DB_sqlite_forge extends CI_DB_forge {
+
+ /**
+ * Create database
+ *
+ * @access public
+ * @param string the database name
+ * @return bool
+ */
+ function _create_database()
+ {
+ // In SQLite, a database is created when you connect to the database.
+ // We'll return TRUE so that an error isn't generated
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Drop database
+ *
+ * @access private
+ * @param string the database name
+ * @return bool
+ */
+ function _drop_database($name)
+ {
+ if ( ! @file_exists($this->db->database) OR ! @unlink($this->db->database))
+ {
+ if ($this->db->db_debug)
+ {
+ return $this->db->display_error('db_unable_to_drop');
+ }
+ return FALSE;
+ }
+ return TRUE;
+ }
+ // --------------------------------------------------------------------
+
+ /**
+ * Create Table
+ *
+ * @access private
+ * @param string the table name
+ * @param array the fields
+ * @param mixed primary key(s)
+ * @param mixed key(s)
+ * @param boolean should 'IF NOT EXISTS' be added to the SQL
+ * @return bool
+ */
+ function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists)
+ {
+ $sql = 'CREATE TABLE ';
+
+ if ($if_not_exists === TRUE)
+ {
+ $sql .= 'IF NOT EXISTS ';
+ }
+
+ $sql .= $this->db->_escape_table($table)." (";
+ $current_field_count = 0;
+
+ foreach ($fields as $field=>$attributes)
+ {
+ // Numeric field names aren't allowed in databases, so if the key is
+ // numeric, we know it was assigned by PHP and the developer manually
+ // entered the field information, so we'll simply add it to the list
+ if (is_numeric($field))
+ {
+ $sql .= "\n\t$attributes";
+ }
+ else
+ {
+ $attributes = array_change_key_case($attributes, CASE_UPPER);
+
+ $sql .= "\n\t".$this->db->_protect_identifiers($field);
+
+ $sql .= ' '.$attributes['TYPE'];
+
+ if (array_key_exists('CONSTRAINT', $attributes))
+ {
+ $sql .= '('.$attributes['CONSTRAINT'].')';
+ }
+
+ if (array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE)
+ {
+ $sql .= ' UNSIGNED';
+ }
+
+ if (array_key_exists('DEFAULT', $attributes))
+ {
+ $sql .= ' DEFAULT \''.$attributes['DEFAULT'].'\'';
+ }
+
+ if (array_key_exists('NULL', $attributes) && $attributes['NULL'] === TRUE)
+ {
+ $sql .= ' NULL';
+ }
+ else
+ {
+ $sql .= ' NOT NULL';
+ }
+
+ if (array_key_exists('AUTO_INCREMENT', $attributes) && $attributes['AUTO_INCREMENT'] === TRUE)
+ {
+ $sql .= ' AUTO_INCREMENT';
+ }
+ }
+
+ // don't add a comma on the end of the last field
+ if (++$current_field_count < count($fields))
+ {
+ $sql .= ',';
+ }
+ }
+
+ if (count($primary_keys) > 0)
+ {
+ $primary_keys = $this->db->_protect_identifiers($primary_keys);
+ $sql .= ",\n\tPRIMARY KEY (" . implode(', ', $primary_keys) . ")";
+ }
+
+ if (count($keys) > 0)
+ {
+ $keys = $this->db->_protect_identifiers($keys);
+ $sql .= ",\n\tUNIQUE (" . implode(', ', $keys) . ")";
+ }
+
+ $sql .= "\n)";
+
+ return $sql;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Drop Table
+ *
+ * Unsupported feature in SQLite
+ *
+ * @access private
+ * @return bool
+ */
+ function _drop_table($table)
+ {
+ if ($this->db->db_debug)
+ {
+ return $this->db->display_error('db_unsuported_feature');
+ }
+ return array();
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Alter table query
+ *
+ * Generates a platform-specific query so that a table can be altered
+ * Called by add_column(), drop_column(), and column_alter(),
+ *
+ * @access private
+ * @param string the ALTER type (ADD, DROP, CHANGE)
+ * @param string the column name
+ * @param string the table name
+ * @param string the column definition
+ * @param string the default value
+ * @param boolean should 'NOT NULL' be added
+ * @param string the field after which we should add the new field
+ * @return object
+ */
+ function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '')
+ {
+ $sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table)." $alter_type ".$this->db->_protect_identifiers($column_name);
+
+ // DROP has everything it needs now.
+ if ($alter_type == 'DROP')
+ {
+ // SQLite does not support dropping columns
+ // http://www.sqlite.org/omitted.html
+ // http://www.sqlite.org/faq.html#q11
+ return FALSE;
+ }
+
+ $sql .= " $column_definition";
+
+ if ($default_value != '')
+ {
+ $sql .= " DEFAULT \"$default_value\"";
+ }
+
+ if ($null === NULL)
+ {
+ $sql .= ' NULL';
+ }
+ else
+ {
+ $sql .= ' NOT NULL';
+ }
+
+ if ($after_field != '')
+ {
+ $sql .= ' AFTER ' . $this->db->_protect_identifiers($after_field);
+ }
+
+ return $sql;
+
+ }
+}
+?> \ No newline at end of file
diff --git a/system/database/drivers/sqlite/sqlite_result.php b/system/database/drivers/sqlite/sqlite_result.php
index caa167813..0939c87b8 100644
--- a/system/database/drivers/sqlite/sqlite_result.php
+++ b/system/database/drivers/sqlite/sqlite_result.php
@@ -167,7 +167,14 @@ class CI_DB_sqlite_result extends CI_DB_result {
}
else
{
- return $this->_fetch_assoc();
+ $arr = sqlite_fetch_array($this->result_id, SQLITE_ASSOC);
+ if (is_array($arr))
+ {
+ $obj = (object) $arr;
+ return $obj;
+ } else {
+ return NULL;
+ }
}
}
diff --git a/system/database/drivers/sqlite/sqlite_utility.php b/system/database/drivers/sqlite/sqlite_utility.php
index 85e74d05f..1c78c54b7 100644
--- a/system/database/drivers/sqlite/sqlite_utility.php
+++ b/system/database/drivers/sqlite/sqlite_utility.php
@@ -24,45 +24,6 @@
*/
class CI_DB_sqlite_utility extends CI_DB_utility {
-
- /**
- * Create database
- *
- * @access public
- * @param string the database name
- * @return bool
- */
- function _create_database()
- {
- // In SQLite, a database is created when you connect to the database.
- // We'll return TRUE so that an error isn't generated
- return TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Drop database
- *
- * @access private
- * @param string the database name
- * @return bool
- */
- function _drop_database($name)
- {
- if ( ! @file_exists($this->db->database) OR ! @unlink($this->db->database))
- {
- if ($this->db->db_debug)
- {
- return $this->db->display_error('db_unable_to_drop');
- }
- return FALSE;
- }
- return TRUE;
- }
-
- // --------------------------------------------------------------------
-
/**
* List databases
*
@@ -86,25 +47,6 @@ class CI_DB_sqlite_utility extends CI_DB_utility {
// --------------------------------------------------------------------
/**
- * Drop Table
- *
- * Unsupported feature in SQLite
- *
- * @access private
- * @return bool
- */
- function _drop_table($table)
- {
- if ($this->db->db_debug)
- {
- return $this->db->display_error('db_unsuported_feature');
- }
- return array();
- }
-
- // --------------------------------------------------------------------
-
- /**
* Optimize table query
*
* Is optimization even supported in SQLite?
@@ -149,6 +91,49 @@ class CI_DB_sqlite_utility extends CI_DB_utility {
return $this->db->display_error('db_unsuported_feature');
}
-}
+ /**
+ *
+ * The functions below have been deprecated as of 1.6, and are only here for backwards
+ * compatibility. They now reside in dbforge(). The use of dbutils for database manipulation
+ * is STRONGLY discouraged in favour if using dbforge.
+ *
+ */
+
+ /**
+ * Create database
+ *
+ * @access public
+ * @param string the database name
+ * @return bool
+ */
+ function _create_database()
+ {
+ // In SQLite, a database is created when you connect to the database.
+ // We'll return TRUE so that an error isn't generated
+ return TRUE;
+ }
+ // --------------------------------------------------------------------
+
+ /**
+ * Drop database
+ *
+ * @access private
+ * @param string the database name
+ * @return bool
+ */
+ function _drop_database($name)
+ {
+ if ( ! @file_exists($this->db->database) OR ! @unlink($this->db->database))
+ {
+ if ($this->db->db_debug)
+ {
+ return $this->db->display_error('db_unable_to_drop');
+ }
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+}
?> \ No newline at end of file
diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php
index 9f3509d51..c3a3ccb5b 100644
--- a/system/helpers/form_helper.php
+++ b/system/helpers/form_helper.php
@@ -231,7 +231,7 @@ function form_dropdown($name = '', $options = array(), $selected = array(), $ext
}
if ($extra != '') $extra = ' '.$extra;
- $multiple = (count($selected) > 1))?' multiple="multiple"':'';
+ $multiple = (count($selected) > 1) ? ' multiple="multiple"' : '';
$form = '<select name="'.$name.'"'.$extra.$multiple.">\n";
diff --git a/system/language/english/db_lang.php b/system/language/english/db_lang.php
index 578972633..c8c48f844 100644
--- a/system/language/english/db_lang.php
+++ b/system/language/english/db_lang.php
@@ -8,7 +8,7 @@ $lang['db_invalid_query'] = 'The query you submitted is not valid.';
$lang['db_must_set_table'] = 'You must set the database table to be used with your query.';
$lang['db_must_use_set'] = 'You must use the "set" method to update an entry.';
$lang['db_must_use_where'] = 'Updates are not allowed unless they contain a "where" clause.';
-$lang['db_del_must_use_where'] = 'Deletes are not allowed unless they contain a "where" clause.';
+$lang['db_del_must_use_where'] = 'Deletes are not allowed unless they contain a "where" or "like" clause.';
$lang['db_field_param_missing'] = 'To fetch fields requires the name of the table as a parameter.';
$lang['db_unsupported_function'] = 'This feature is not available for the database you are using.';
$lang['db_transaction_failure'] = 'Transaction failure: Rollback performed.';
@@ -17,8 +17,8 @@ $lang['db_unsuported_feature'] = 'Unsupported feature of the database platform y
$lang['db_unsuported_compression'] = 'The file compression format you chose is not supported by your server.';
$lang['db_filepath_error'] = 'Unable to write data to the file path you have submitted.';
$lang['db_invalid_cache_path'] = 'The cache path you submitted is not valid or writable.';
-
-
-
+$lang['db_table_name_required'] = 'A table name is required for that operation.';
+$lang['db_column_name_required'] = 'A column name is required for that operation.';
+$lang['db_column_definition_required'] = 'A column definition is required for that operation.';
?> \ No newline at end of file
diff --git a/system/language/english/email_lang.php b/system/language/english/email_lang.php
index 040e0eaa3..430ae4ab2 100644
--- a/system/language/english/email_lang.php
+++ b/system/language/english/email_lang.php
@@ -1,21 +1,21 @@
-<?php
-
-$lang['email_must_be_array'] = "The email validation method must be passed an array.";
-$lang['email_invalid_address'] = "Invalid email address: %s";
-$lang['email_attachment_missing'] = "Unable to locate the following email attachment: %s";
-$lang['email_attachment_unreadable'] = "Unable to open this attachment: %s";
-$lang['email_no_recipients'] = "You must include recipients: To, Cc, or Bcc";
-$lang['email_send_failure_phpmail'] = "Unable to send email using PHP mail(). Your server might not be configured to send mail using this method.";
-$lang['email_send_failure_sendmail'] = "Unable to send email using PHP Sendmail. Your server might not be configured to send mail using this method.";
-$lang['email_send_failure_smtp'] = "Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.";
-$lang['email_sent'] = "Your message has been successfully sent using the following protocol: %s";
-$lang['email_no_socket'] = "Unable to open a socket to Sendmail. Please check settings.";
-$lang['email_no_hostname'] = "You did not specify a SMTP hostname";
-$lang['email_smtp_error'] = "The following SMTP error was encountered: %s";
-$lang['email_no_smtp_unpw'] = "Error: You must assign a SMTP username and password.";
-$lang['email_failed_smtp_login'] = "Failed to send AUTH LOGIN command. Error: %s";
-$lang['email_smtp_auth_un'] = "Failed to authenticate username. Error: %s";
-$lang['email_smtp_auth_pw'] = "Failed to authenticate password. Error: %s";
-$lang['email_smtp_data_failure'] = "Unable to send data: %s";
-
+<?php
+
+$lang['email_must_be_array'] = "The email validation method must be passed an array.";
+$lang['email_invalid_address'] = "Invalid email address: %s";
+$lang['email_attachment_missing'] = "Unable to locate the following email attachment: %s";
+$lang['email_attachment_unredable'] = "Unable to open this attachment: %s";
+$lang['email_no_recipients'] = "You must include recipients: To, Cc, or Bcc";
+$lang['email_send_failure_phpmail'] = "Unable to send email using PHP mail(). Your server might not be configured to send mail using this method.";
+$lang['email_send_failure_sendmail'] = "Unable to send email using PHP Sendmail. Your server might not be configured to send mail using this method.";
+$lang['email_send_failure_smtp'] = "Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.";
+$lang['email_sent'] = "Your message has been successfully sent using the following protocol: %s";
+$lang['email_no_socket'] = "Unable to open a socket to Sendmail. Please check settings.";
+$lang['email_no_hostname'] = "You did not specify a SMTP hostname";
+$lang['email_smtp_error'] = "The following SMTP error was encountered: %s";
+$lang['email_no_smtp_unpw'] = "Error: You must assign a SMTP username and password.";
+$lang['email_filed_smtp_login'] = "Failed to send AUTH LOGIN command. Error: %s";
+$lang['email_smtp_auth_un'] = "Failed to authenticate username. Error: %s";
+$lang['email_smtp_auth_pw'] = "Failed to authenticate password. Error: %s";
+$lang['email_smtp_data_failure'] = "Unable to send data: %s";
+
?> \ No newline at end of file
diff --git a/system/libraries/Loader.php b/system/libraries/Loader.php
index 99652c0b8..f833cb713 100644
--- a/system/libraries/Loader.php
+++ b/system/libraries/Loader.php
@@ -236,16 +236,45 @@ class CI_Loader {
}
$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();
require_once(BASEPATH.'database/DB_utility'.EXT);
require_once(BASEPATH.'database/drivers/'.$CI->db->dbdriver.'/'.$CI->db->dbdriver.'_utility'.EXT);
$class = 'CI_DB_'.$CI->db->dbdriver.'_utility';
- $CI->dbutil = new $class();
+ $CI->dbutil =& new $class();
+
$CI->load->_ci_assign_to_models();
}
// --------------------------------------------------------------------
+
+ /**
+ * Load the Database Forge Class
+ *
+ * @access public
+ * @return string
+ */
+ function dbforge()
+ {
+ if ( ! class_exists('CI_DB'))
+ {
+ $this->database();
+ }
+
+ $CI =& get_instance();
+
+ require_once(BASEPATH.'database/DB_forge'.EXT);
+ require_once(BASEPATH.'database/drivers/'.$CI->db->dbdriver.'/'.$CI->db->dbdriver.'_forge'.EXT);
+ $class = 'CI_DB_'.$CI->db->dbdriver.'_forge';
+
+ $CI->dbforge = new $class();
+ }
+
+ // --------------------------------------------------------------------
/**
* Load View
diff --git a/user_guide/changelog.html b/user_guide/changelog.html
index 8fa74a13b..902e5e647 100644
--- a/user_guide/changelog.html
+++ b/user_guide/changelog.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="./toc.html">Table of Contents Page</a></td>
</tr>
</table>
@@ -57,7 +57,7 @@ Change Log
<h1>Change Log</h1>
-<h2>Version 1.5.5</h2>
+<h2>Version 1.6.0</h2>
<p>Release Date: -- still in development </p>
<ul>
<li>Added Flashdata variables, session_id regeneration and configurable session update times to the <a href="./libraries/sessions.html">Session class.</a></li>
@@ -66,30 +66,42 @@ Change Log
<li>Added <dfn>$assign_to_controller</dfn> variable in the main <kbd>index.php</kbd> file. Anything that this variable contains will be passed automatically to a controller constructor when initialized.</li>
<li>Reorganized the URI and Routes classes for better clarity.</li>
<li>Javascript Calendar plugin now uses the months and days from the calendar language file, instead of hard-coded values, internationalizing it.</li>
- <li>Removed &quot;rand()&quot; as a listed option from orderby in the <a href="./database/active_record.html">Active Record</a>, as it was MySQL only.</li>
- <li>Added 'random' as an <kbd>order_by()</kbd> option in <a href="./database/active_record.html">Active Record</a>.</li>
- <li>Added <kbd>where_in()</kbd>, <kbd>where_in_or()</kbd>, <kbd>where_not_in()</kbd>, and <kbd>where_not_in_or()</kbd> to <a href="./database/active_record.html">Active Record</a>.</li>
- <li>Added support for <kbd>limit()</kbd> into <kbd>update()</kbd> and <kbd>delete()</kbd> statements in <a href="./database/active_record.html">Active Record</a>.</li>
+ <li>Added <a href="./database/forge.html">DBForge</a> to the database tools.</li>
+ <li>Moved <kbd>create_database()</kbd> and <kbd>drop_database()</kbd> into <a href="./database/forge.html">DBForge</a>.</li>
+ <li>Added <kbd>add_field()</kbd>, <kbd>add_key()</kbd>, <kbd>create_table()</kbd>, <kbd>drop_table()</kbd>, <kbd>add_column()</kbd>, <kbd>drop_column()</kbd>, <kbd>modify_column()</kbd> into <a href="./database/forge.html">DBForge</a>.</li>
+ <li>Added 'random' as an <kbd>order_by()</kbd> option , and removed &quot;rand()&quot; as a listed option as it was MySQL only.</li>
+ <li>Added <kbd>protect_identifiers()</kbd> in <a href="./database/active_record.html">Active Record</a>.</li>
+ <li>Alll AR queries are backticked if appropriate to the database.</li>
+ <li>Added <kbd>where_in()</kbd>, <kbd>where_in_or()</kbd>, <kbd>where_not_in()</kbd>, <kbd>where_not_in_or()</kbd>, <kbd>not_like()</kbd> and <kbd>or_not_like()</kbd> to <a href="./database/active_record.html">Active Record</a>.</li>
+ <li>Added support for <kbd>limit()</kbd> into <kbd>update()</kbd> and <kbd>delete()</kbd> statements in <a href="./database/active_record.html">Active Record</a>.</li>
+ <li>Added <kbd>empty_table()</kbd> and <kbd>truncate_table()</kbd> to <a href="./database/active_record.html">Active Record</a>.</li>
<li>Added the ability to pass an array of tables to the <kbd>delete()</kbd> statement in <a href="./database/active_record.html">Active Record</a>.</li>
- <li>Added titles to all user manual pages.</li>
+ <li>Added <kbd>count_all_results()</kbd> function to <a href="./database/active_record.html">Active Record</a>.</li>
+ <li>Added <kbd>select_max()</kbd>, <kbd>select_min()</kbd>, <kbd>select_avg()</kbd> and <kbd>select_sum()</kbd> to <a href="./database/active_record.html">Active Record</a>.</li>
+ <li>Added the ability to use aliases with joins in <a href="./database/active_record.html">Active Record</a>.</li>
+ <li>Added a third parameter to Active Record's <kbd>like()</kbd> clause to control where the wildcard goes. </li>
+ <li>Added a third parameter to <kbd>set()</kbd> in <a href="./database/active_record.html">Active Record</a> that withholds escaping data.</li>
<li>Added a check for NULL fields in the MySQL database backup utility.</li>
- <li>Documented the <kbd>timezones()</kbd> function in the <a href="./helpers/date_helper.html">Date Helper</a>.</li>
- <li>Documented unset_userdata in the <a href="./libraries/sessions.html">Session class</a>.</li>
- <li>Documented <kbd>distinct()</kbd> in <a href="./database/active_record.html">Active Record</a>. </li>
- <li>Changed the behaviour of custom callbacks so that they no longer trigger the &quot;required&quot; rule. </li>
<li>Added a few additional mime type variations for CSV.</li>
<li>Added <kbd>strip_quotes()</kbd> function to <a href="./helpers/string_helper.html">string helper</a>.</li>
<li>Added <kbd>reduce_multiples()</kbd> function to <a href="./helpers/string_helper.html">string helper</a>.</li>
<li>Added <kbd>quotes_to_entities()</kbd> function to <a href="./helpers/string_helper.html">string helper</a>.</li>
- <li>Added <kbd>form_reset()</kbd> function to <a href="./helpers/form_helper.html">form helper</a>.</li>
- <li>Added <kbd>count_all_results()</kbd> function to <a href="./database/active_record.html">Active Record</a>.</li>
- <li>Added the ability to use aliases with joins in <a href="./database/active_record.html">Active Record</a>.</li>
+ <li>Added <kbd>form_fieldset()</kbd>, <kbd>form_fieldset_close()</kbd>, <kbd>form_label()</kbd>, and <kbd>form_reset()</kbd> function to <a href="./helpers/form_helper.html">form helper</a>.</li>
+ <li>Added support for external urls in <kbd>form_open()</kbd>.</li>
<li>Added a language entry for valid_ip validation error.</li>
- <li>Added a third parameter to Active Record's <kbd>like()</kbd> clause to control where the wildcard goes. </li>
+ <li>Added titles to all user manual pages.</li>
+ <li>Added <a href="http://codeigniter.com/user_guide/libraries/zip.html">Zip Encoding Class</a> to the table of contents of the userguide.</li>
<li>Moved the safe mode and auth checks for the Email library into the constructor. </li>
+ <li>Moved part of the userguide menu javascript to an external file.</li>
+ <li>Changed the behaviour of custom callbacks so that they no longer trigger the &quot;required&quot; rule. </li>
<li>Changed the behaviour of variables submitted to the where() clause with no values to auto set &quot;IS NULL&quot;</li>
+ <li>Documented <kbd>distinct()</kbd> in <a href="./database/active_record.html">Active Record</a>. </li>
+ <li>Documented the <kbd>timezones()</kbd> function in the <a href="./helpers/date_helper.html">Date Helper</a>.</li>
+ <li>Documented unset_userdata in the <a href="./libraries/sessions.html">Session class</a>.</li>
+ <li>Documented 2 config options to the <a href="./database/configuration.html">Database configuration</a> page.</li>
<li>Fixed a bug in <kbd>highlight_pharse()</kbd> that caused an error with slashes.</li>
- <li>Fixed a bug: $field_names[] vs $Ffield_names[] in postgre and sqlite drivers</li>
+ <li>Fixed a bug: $field_names[] vs $Ffield_names[] in postgre and sqlite drivers.</li>
+ <li>Fixed a bug in the <a href="./libraries/file_uploading.html">upload library</a> when allowed_files wasn't defined.</li>
<li>Fixed a bug in <kbd>word_wrap()</kbd> of the Text Helper that incorrectly referenced an object. </li>
<li>Fixed a bug in the <a href="./libraries/email.html">Email</a> library where some timezones were calculated incorrectly. </li>
<li>Fixed a bug in <a href="./libraries/validation.html">Validation</a> where <kbd>valid_ip()</kbd> wasn't called properly.</li>
@@ -102,19 +114,22 @@ Change Log
<li>Fixed a bug that was making validation callbacks required even when not set as such.</li>
<li>Fixed a bug in _object_to_array that broke some types of inserts and updates.</li>
<li>Fixed a bug in <kbd>get_filenames()</kbd> in the <a href="./helpers/file_helper.html">File Helper </a>where the array wasn't cleared after each call.</li>
+ <li>Fixed a bug that prevented num_rows from working in Oracle.</li>
+ <li>Fixed a bug in the <a href="./libraries/parser.html">parser class</a> where numeric data was ignored.</li>
+ <li>Fixed a bug when loading plugin files as _plugin. and not _pi.</li>
+ <li>Fixed a bug in the SQLite driver for PHP 4.</li>
<li>Fixed an example of comma-separated emails in the email library documentation.</li>
<li>Fixed an example in the Calendar library for Showing Next/Previous Month Links.</li>
<li>Fixed a typo in the database language file.</li>
- <li>Fixed a typo in the image language file &quot;suppor&quot; to &quot;support&quot;. </li>
+ <li>Fixed a typo in the image language file &quot;suppor&quot; to &quot;support&quot;.</li>
<li>Fixed an example for XML RPC.</li>
- <li>Fixed an example of <kbd>accept_charset()</kbd> in the <a href="./libraries/user_agent.html">User Agent Library</a>. </li>
- <li>Fixed a typo in the docblock comments that had CodeIgniter spelled CodeIgnitor. </li>
- <li>Fixed a typo in the <a href="./helpers/string_helper.html">String Helper</a> (uniquid changed to uniqid) </li>
+ <li>Fixed an example of <kbd>accept_charset()</kbd> in the <a href="./libraries/user_agent.html">User Agent Library</a>.</li>
+ <li>Fixed a typo in the docblock comments that had CodeIgniter spelled CodeIgnitor.</li>
+ <li>Fixed a typo in the <a href="./helpers/string_helper.html">String Helper</a> (uniquid changed to uniqid).</li>
+ <li>Fixed typos in the email Language class (email_attachment_unredable, email_filed_smtp_login).</li>
<li>Fixed assorted user guide typos.</li>
- <li>Moved part of the userguide menu javascript to an external file.</li>
- <li>Added <a href="http://codeigniter.com/user_guide/libraries/zip.html">Zip Encoding Class</a> to the table of contents of the userguide.</li>
- <li>Deprecated from Active Record; <kbd>getwhere()</kbd> for <kbd>get_where()</kbd>; <kbd>groupby()</kbd> for <kbd>group_by()</kbd>; <kbd>orderby()</kbd> for <kbd>order_by</kbd>; <kbd>orwhere()</kbd> for <kbd>or_where()</kbd>; and <kbd>orlike()</kbd> for <kbd>or_like()</kbd>.</li>
-</ul>
+ <li>Deprecated from Active Record; <kbd>getwhere()</kbd> for <kbd>get_where()</kbd>; <kbd>groupby()</kbd> for <kbd>group_by()</kbd>; <kbd>havingor()</kbd> for <kbd>having_or()</kbd>; <kbd>orderby()</kbd> for <kbd>order_by</kbd>; <kbd>orwhere()</kbd> for <kbd>or_where()</kbd>; and <kbd>orlike()</kbd> for <kbd>or_like()</kbd>.</li>
+ </ul>
diff --git a/user_guide/database/active_record.html b/user_guide/database/active_record.html
index d43101642..45cabdbaa 100644
--- a/user_guide/database/active_record.html
+++ b/user_guide/database/active_record.html
@@ -27,7 +27,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
@@ -128,19 +128,53 @@ instead of using the db->where() function:</p>
<p>Please read the about the where function below for more information.</p>
<p class="important">Note: get_where() was formerly known as getwhere(), which has been deprecated</p>
-<h2>$this->db->select();</h2>
+<h2>$this->db->select();</h2>
<p>Permits you to write the SELECT portion of your query:</p>
-
-<code>
+<p><code>
$this->db->select('title, content, date');<br />
<br />
$query = $this->db->get('mytable');<br />
<br />
-// Produces: SELECT title, content, date FROM mytable</code>
+// Produces: SELECT title, content, date FROM mytable</code></p>
+<p class="important"><strong>Note:</strong> If you are selecting all (*) from a table you do not need to use this function. When omitted, CodeIgniter assumes you wish to SELECT *</p>
-<p><strong>Note: If you are selecting all (*) from a table you do not need to use this function. When omitted, CodeIgniter assumes you wish to SELECT *</strong></p>
+<p>$this-&gt;Db-&gt;select() accepts an optional second parameter. If you set it to FALSE, CodeIgniter will not try to protect your field or table names with backticks. This is useful if you need a compound select statement.</p>
+<p><code> $this-&gt;db-&gt;select('(SELECT SUM(payments.amount) FROM payments WHERE payments.invoice_id=4') AS amount_paid', FALSE); <br />
+ $query = $this-&gt;db-&gt;get('mytable');<br />
+</code></p>
+<h2>$this->db->select_max();</h2>
+<p>Writes a "SELECT MAX(field)" portion for your query. You can optionally include a second parameter to rename the resulting field.</p>
+<p><code>
+$this->db->select_max('age');<br />
+$query = $this->db->get('members');<br />
+// Produces: SELECT MAX(age) as age FROM members<br />
+<br />
+$this-&gt;db-&gt;select_max('age', 'member_age');<br />
+$query = $this-&gt;db-&gt;get('members');<br />
+// Produces: SELECT MAX(age) as member_age FROM members</code></p>
+
+<h2>$this->db->select_min();</h2>
+<p>Writes a "SELECT MIN(field)" portion for your query. As with <dfn>select_max()</dfn>, You can optionally include a second parameter to rename the resulting field.</p>
+<p><code>
+$this->db->select_min('age');<br />
+$query = $this->db->get('members');<br />
+// Produces: SELECT MIN(age) as age FROM members</code></p>
+
+<h2>$this->db->select_avg();</h2>
+<p>Writes a "SELECT AVG(field)" portion for your query. As with <dfn>select_max()</dfn>, You can optionally include a second parameter to rename the resulting field.</p>
+<p><code>
+$this->db->select_avg('age');<br />
+$query = $this->db->get('members');<br />
+// Produces: SELECT AVG(age) as age FROM members</code></p>
+
+<h2>$this->db->select_sum();</h2>
+<p>Writes a "SELECT SUM(field)" portion for your query. As with <dfn>select_max()</dfn>, You can optionally include a second parameter to rename the resulting field.</p>
+<p><code>
+$this->db->select_sum('age');<br />
+$query = $this->db->get('members');<br />
+// Produces: SELECT SUM(age) as age FROM members</code></p>
<h2>$this->db->from();</h2>
@@ -154,8 +188,8 @@ $query = $this->db->get();<br />
<br />
// Produces: SELECT title, content, date FROM mytable</code>
-<p><strong>Note: As shown earlier, the FROM portion of your query can be specified in the <dfn>$this->db->get()</dfn> function, so use whichever method
-you prefer.</strong></p>
+<p class="important">Note: As shown earlier, the FROM portion of your query can be specified in the <dfn>$this->db->get()</dfn> function, so use whichever method
+you prefer.</p>
<h2>$this->db->join();</h2>
@@ -294,6 +328,19 @@ $this->db->or_where('id >', $id);
$this->db->where_in('username', $names);<br />
// Produces: OR WHERE username NOT IN ('Frank', 'Todd', 'James')</code></p>
+<h2>$this->db->raw_where();</h2>
+<p> Generates an unfiltered WHERE portion of the query exactly as the developer passes it. Separates multiple calls with AND<br />
+ <code> $this->db->raw_where('(grade &gt; 50 AND grade &lt; 75)');<br />
+ // Produces: AND WHERE (grade &gt; 50 AND grade &lt; 75)</code></p>
+
+<h2>$this->db->raw_or_where();</h2>
+<p> Generates an unfiltered WHERE portion of the query exactly as the developer passes it. Separates multiple calls with OR<br />
+ <code> $this->db->raw_where('(grade &gt; 50 AND grade &lt; 75)');<br />
+ // Produces: OR WHERE (grade &gt; 50 AND grade &lt; 75)</code></p>
+
+<p class="important"><strong>Note:</strong> All values passed through raw_where() and raw_or_where() are <strong>not</strong> escaped automatically, or otherwise touched. It is the responsibility of the developer to ensure all queries are safe. Consider using <a href="queries.html"><dfn>protect_identifiers()</dfn></a> and <a href="helpers.html">escaping your queries </a>as appropriate.</p>
+
+
<h2>$this->db->like();</h2>
<p>This function enables you to generate <strong>LIKE</strong> clauses, useful for doing searches.</p>
@@ -390,11 +437,12 @@ $this-&gt;db-&gt;or_not_like('body', 'match'); <br />
<code>$this->db->having(array('title =' => 'My Title', 'id <' => $id));
-<br /><br />// Produces: HAVING title = 'My Title', 'id < 45'
-</code>
+<br /><br />// Produces: HAVING title = 'My Title', 'id < 45'</code>
+<h2>$this-&gt;db-&gt;or_having();</h2>
+<p>Identical to having(), only separates multiple clauses with &quot;OR&quot;.</p>
<h2>$this->db->order_by();</h2>
<p>Lets you set an ORDER BY clause. The first parameter contains the name of the column you would like to order by.
The second parameter lets you set the direction of the result. Options are <kbd>asc</kbd> or <kbd>desc</kbd>, or <kbd>random</kbd>. </p>
@@ -419,7 +467,7 @@ The second parameter lets you set the direction of the result. Options are <kbd
// Produces: ORDER BY title DESC, name ASC
</code></p>
<p class="important">Note: order_by() was formerly known as orderby(), which has been deprecated.</p>
-<p class="important">Note: random ordering is not currently supported in Orcacle or MSSQL drivers. </p>
+<p class="important">Note: random ordering is not currently supported in Orcacle or MSSQL drivers. These will default to 'ASC'.</p>
<h2>$this->db->limit();</h2>
<p>Lets you limit the number of rows you would like returned by the query:</p>
@@ -516,14 +564,19 @@ $this->db->insert('mytable');
<p>If you use multiple function called they will be assembled properly based on whether you are doing an insert or an update:</p>
-<code>$this->db->set('name', $name);<br />
-$this->db->set('title', $title);<br />
-$this->db->set('status', $status);<br />
-$this->db->insert('mytable');
-</code>
-
+<code>$this-&gt;db-&gt;set('name', $name);<br />
+$this-&gt;db-&gt;set('title', $title);<br />
+$this-&gt;db-&gt;set('status', $status);<br />
+$this-&gt;db-&gt;insert('mytable'); </code>
+<p><strong>set()</strong> will also accept an optional third parameter ($escape), that will prevent data from being escaped if set to FALSE. To illustrate the difference, here is set() used both with and without the escape parameter.</p>
+<p><code>$this-&gt;db-&gt;set('field', 'field+1', FALSE);<br />
+ $this-&gt;db-&gt;insert('mytable'); <br />
+ // gives INSERT INTO mytable (field) VALUES (field+1)<br />
+ <br />
+ $this-&gt;db-&gt;set('field', 'field+1');<br />
+ $this-&gt;db-&gt;insert('mytable'); <br />
+ // gives INSERT INTO mytable (field) VALUES ('field+1')</code></p>
<p>You can also pass an associative array to this function:</p>
-
<code>
$array = array('name' => $name, 'title' => $title, 'status' => $status);<br /><br />
@@ -640,9 +693,23 @@ the data to the second parameter of the function:</p>
<p><code>$tables = array('table1', 'table2', 'table3');<br />
$this-&gt;db-&gt;where('id', '5');<br />
$this-&gt;db-&gt;delete($tables);</code></p>
-<p class="important"><strong>Note:</strong> All values are escaped automatically producing safer queries.</p>
-
-
+<p>If you want to delete all data from a table, you can use the <dfn>truncate()</dfn> function, or <dfn>empty_table()</dfn>.</p>
+<h2>$this-&gt;db-&gt;empty_table();</h2>
+<p>Generates a delete SQL string and runs the query.<code> $this-&gt;db-&gt;empty_table('mytable'); <br />
+ <br />
+// Produces<br />
+// DELETE FROM mytable</code></p>
+<h2>$this-&gt;db-&gt;truncate();</h2>
+<p>Generates a truncate SQL string and runs the query.</p>
+<code> $this-&gt;db-&gt;from('mytable'); <br />
+$this-&gt;db-&gt;truncate(); <br />
+// or <br />
+$this-&gt;db-&gt;truncate('mytable'); <br />
+<br />
+// Produce:<br />
+// TRUNCATE mytable <br />
+</code>
+<p class="important"><strong>Note:</strong> If the TRUNCATE command isn't available, truncate() will execute as &quot;DELETE FROM table&quot;.</p>
<a name="chaining">&nbsp;</a>
<h1>Method Chaining</h1>
diff --git a/user_guide/database/caching.html b/user_guide/database/caching.html
index d2cbd9c8e..11cc3f5ce 100644
--- a/user_guide/database/caching.html
+++ b/user_guide/database/caching.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/database/call_function.html b/user_guide/database/call_function.html
index f61b6f7e8..6157acfa7 100644
--- a/user_guide/database/call_function.html
+++ b/user_guide/database/call_function.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/database/configuration.html b/user_guide/database/configuration.html
index b9b61d32c..f6097f2b7 100644
--- a/user_guide/database/configuration.html
+++ b/user_guide/database/configuration.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/database/connecting.html b/user_guide/database/connecting.html
index 04c0c2c4d..96dd1f06a 100644
--- a/user_guide/database/connecting.html
+++ b/user_guide/database/connecting.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/database/examples.html b/user_guide/database/examples.html
index 8989b961c..bcda80f81 100644
--- a/user_guide/database/examples.html
+++ b/user_guide/database/examples.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/database/fields.html b/user_guide/database/fields.html
index 6dc4eeb8a..ab0920754 100644
--- a/user_guide/database/fields.html
+++ b/user_guide/database/fields.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/database/forge.html b/user_guide/database/forge.html
new file mode 100644
index 000000000..90991a9c5
--- /dev/null
+++ b/user_guide/database/forge.html
@@ -0,0 +1,221 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html>
+<head>
+
+<title>CodeIgniter User Guide : Database Utility Class</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='Rick Ellis' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle.jpg" width="153" height="44" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://www.codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+<a href="index.html">Database Library</a> &nbsp;&#8250;&nbsp;
+Database Utility Class
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+<h1>Database Forge Class</h1>
+
+<p>The Database Forge Class contains functions that help you manage your database.</p>
+
+<h3>Table of Contents</h3>
+
+<ul>
+<li><a href="#init">Initializing the Forge Class</a></li>
+<li><a href="#create">Creating a Database</a></li>
+<li><a href="#drop">Dropping a Database</a></li>
+<li><a href="#add_field">Adding Fields</a></li>
+<li><a href="#add_key">Adding Keys</a></li>
+<li><a href="#create_table">Creating a Table</a></li>
+<li><a href="#drop_table">Dropping a Table</a></li>
+<li><a href="#modifying_tables">Modifying a Table</a></li>
+</ul>
+
+
+<h2><a name="init"></a>Initializing the Forge Class</h2>
+
+<p class="important"><strong>Important:</strong>&nbsp; In order to initialize the Forge class, your database driver must
+already be running, since the forge class relies on it.</p>
+
+<p>Load the Forge Class as follows:</p>
+
+<code>$this->load->dbforge()</code>
+
+<p>Once initialized you will access the functions using the <dfn>$this->dbforge</dfn> object:</p>
+
+<code>$this->dbforge->some_function()</code>
+<h2><a name="create"></a>$this->dbforge->create_database('db_name')</h2>
+
+<p>Permits you to create the database specified in the first parameter. Returns TRUE/FALSE based on success or failure:</p>
+
+<code>if ($this->dbutil->create_database('my_db'))<br />
+{<br />
+&nbsp;&nbsp;&nbsp; echo 'Database created!';<br />
+}</code>
+
+
+
+
+<h2><a name="drop"></a>$this->dbforge->drop_database('db_name')</h2>
+
+<p>Permits you to drop the database specified in the first parameter. Returns TRUE/FALSE based on success or failure:</p>
+
+<code>if ($this->dbutil->drop_database('my_db'))<br />
+{<br />
+&nbsp;&nbsp;&nbsp; echo 'Database deleted!';<br />
+}</code>
+
+
+<h1>Creating and Dropping Tables</h1>
+<p>There are several things you may wish to do when creating tables. Add fields, add keys to the table, alter columns. CodeIgniter provides a mechanism for this.</p>
+<h2><a name="add_field" id="add_field"></a>Adding fields</h2>
+<p>Fields are created via an associative array. Within the array you must include a 'type' key that relates to the datatype of the field. For example, INT, VARCHAR, TEXT, etc. Many datatypes (for example VARCHAR) also require a 'constraint' key.</p>
+<p><code>$fields = array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'users' =&gt; array(<br />
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'type' =&gt; 'varchar',<br />
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'constraint' =&gt; '100',<br />
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;),<br />
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);<br />
+ <br />
+// will translate to &quot;users VARCHAR(100)&quot; when the field is added.</code></p>
+<p>Additionally, the following key/values can be used:</p>
+<ul>
+ <li>unsigned/true : to generate &quot;UNSIGNED&quot; in the field definition</li>
+ <li>default/value : to generate a default value in the field definition</li>
+ <li>null/true : to generate &quot;NULL&quot; in the field definition. Without this, the field will default to &quot;NOT NULL&quot;</li>
+ <li>auto_increment/true : generates an auto_increment flag on the field. Note that the field type must </li>
+ </ul>
+<p><code>$fields = array(<br />
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'blog_id' =&gt; array(<br />
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'type' =&gt; 'INT',<br />
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'constraint' =&gt; 5, <br />
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'unsigned' =&gt; TRUE,<br />
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'auto_increment' =&gt; TRUE<br />
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;),<br />
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'blog_title' =&gt; array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'type' =&gt; 'VARCHAR',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'constraint' =&gt; '100',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;),<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'blog_author' =&gt; array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'type' =&gt;'VARCHAR',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'constraint' =&gt; '100',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'default' =&gt; 'King of Town',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;),<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'blog_description' =&gt; array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'type' =&gt; 'TEXT',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'null' =&gt; TRUE,<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;),<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);<br />
+ );</code></p>
+<p>After the fields have been defined, they can be added using <dfn>$this-&gt;dbforge-&gt;add_field($fields);</dfn> followed by a call to the <dfn>create_table()</dfn> function.</p>
+<h3>$this-&gt;dbforge-&gt;add_field()</h3>
+<p>The add fields function will accept the above array.</p>
+<h3>Passing strings as fields</h3>
+<p>If you know exactly how you want a field to be created, you can pass the string into the field definitions with add_field()</p>
+<p><code>$this-&gt;dbforge-&gt;add_field(&quot;label varchar(100) NOT NULL DEFAULT 'default label'&quot;);</code></p>
+<p class="important">Note: Multiple calls to <dfn>add_field()</dfn> are cumulative.</p>
+<h3>Creating an id field</h3>
+<p>There is a special exception for creating id fields. A field with type id will automatically be assinged as an INT(9) auto_incrementing Primary Key.</p>
+<p><code>$this-&gt;dbforge-&gt;add_field('id');<br />
+ // gives id INT(9) NOT NULL AUTO_INCREMENT</code></p>
+<h2><a name="add_key" id="add_key"></a>Adding Keys</h2>
+<p>Generally speaking, you'll want your table to have Keys. This is accomplished with <dfn>$this-&gt;dbforge-&gt;add_key('field')</dfn>. An optional second parameter set to TRUE will make it a primary key. Note that <dfn>add_key()</dfn> must be followed by a call to <dfn>create_table()</dfn>.</p>
+<p><code>$this-&gt;dbforge-&gt;add_key('blog_id', TRUE);<br />
+ // gives PRIMARY KEY (blog_id)<br />
+ <br />
+ $this-&gt;dbforge-&gt;add_key('blog_name');<br />
+ // gives KEY (blog_name)</code></p>
+<h2><a name="create_table" id="create_table2"></a>Creating a table</h2>
+<p>After fields and keys have been declared, you can create a new table with</p>
+<p><code>$this-&gt;dbforge-&gt;create_table('table_name')<br />
+// gives CREATE TABLE table_name</code></p>
+<p>An optional second parameter set to TRUE adds an &quot;IF NOT EXISTS&quot; clause into the definition</p>
+<p><code>$this-&gt;dbforge-&gt;create_table('table_name')<br />
+// gives CREATE TABLE IF NOT EXISTS table_name</code></p>
+<h2><a name="drop_table" id="drop_table"></a>Dropping a table</h2>
+<p>Executes a DROP TABLE sql</p>
+<p><code>$this-&gt;dbforge-&gt;drop_table('table_name')<br />
+// gives DROP TABLE IF EXISTS table_name</code></p>
+<h1><a name="modifying_tables" id="drop_table2"></a>Modifying Tables</h1>
+<h2>$this-&gt;dbforge-&gt;add_column()</h2>
+<p>The add_column() function 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.</p>
+<p><code>$fields = array(<br />
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'preferences' =&gt; array('type' =&gt; 'TEXT')<br />
+);<br />
+$this-&gt;dbforge-&gt;add_column('table_name', $fields);<br />
+<br />
+// gives ALTER TABLE sites ADD preferences TEXT</code></p>
+<h2>$this-&gt;dbforge-&gt;drop_column()</h2>
+<p>Used to remove a column from a table. </p>
+<p><code>$this-&gt;dbforge-&gt;drop_column('table_name', 'column_to_drop');</code></p>
+<h2>$this-&gt;dbforge-&gt;modify_column()</h2>
+<p>The usage of this function is identical to add_coumn(), except it alters an existing column rather than adding a new one. In order to use it you must add a &quot;name&quot; key into the field defining array.</p>
+<p><code>$fields = array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'old_name' =&gt; array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'name' =&gt; 'new_name',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'type' =&gt; 'TEXT',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;),<br />
+);<br />
+$this-&gt;dbforge-&gt;modify_column('sites', $fields);<br />
+ <br />
+ // gives ALTER TABLE sites CHANGE old_name new_name TEXT </code></p>
+<p>&nbsp;</p>
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="caching.html">DB Caching Class</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="utilities.html">Database Utilities Class</a><a href="../libraries/email.html"></a></p>
+<p><a href="http://www.codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2007 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">Ellislab, Inc.</a></p>
+</div>
+
+</body>
+</html> \ No newline at end of file
diff --git a/user_guide/database/helpers.html b/user_guide/database/helpers.html
index 6db89e0cc..93b9a6ddc 100644
--- a/user_guide/database/helpers.html
+++ b/user_guide/database/helpers.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/database/index.html b/user_guide/database/index.html
index 7ad5ace42..d4319b918 100644
--- a/user_guide/database/index.html
+++ b/user_guide/database/index.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
@@ -75,7 +75,8 @@ structures and Active Record patterns. The database functions offer clear, simpl
<li><a href="fields.html">Field MetaData</a></li>
<li><a href="call_function.html">Custom Function Calls</a></li>
<li><a href="caching.html">Query Caching</a></li>
- <li><a href="utilities.html">Database Utilities Class</a></li>
+ <li><a href="forge.html">Database manipulation with Database Forge</a></li>
+ <li><a href="utilities.html">Database Utilities Class</a></li>
</ul>
diff --git a/user_guide/database/queries.html b/user_guide/database/queries.html
index e1d346c38..3ff8cc70f 100644
--- a/user_guide/database/queries.html
+++ b/user_guide/database/queries.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
@@ -80,8 +80,10 @@ It DOES NOT return a database result set, nor does it set the query timer, or co
It simply lets you submit a query. Most users will rarely use this function.</p>
+<h1>Protecting identifiers</h1>
+<p>In many databases it is advisable to protect table and field names - for example with backticks in MySQL. Active Record queries are automatically protected, however if you need to manually protect an identifier you can use:</p>
+<p><code>$this-&gt;db-&gt;protect_identifier('table_name');</code></p>
<h1>Escaping Queries</h1>
-
<p>It's a very good security practice to escape your data before submitting it into your database.
CodeIgniter has two functions that help you do this:</p>
diff --git a/user_guide/database/results.html b/user_guide/database/results.html
index 9ce6a310c..31b07567d 100644
--- a/user_guide/database/results.html
+++ b/user_guide/database/results.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/database/table_data.html b/user_guide/database/table_data.html
index 22e05c108..16c3bba91 100644
--- a/user_guide/database/table_data.html
+++ b/user_guide/database/table_data.html
@@ -1 +1,113 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>CodeIgniter User Guide : Table Data</title> <style type='text/css' media='all'>@import url('../userguide.css');</style> <link rel='stylesheet' type='text/css' media='all' href='../userguide.css' /> <script type="text/javascript" src="../nav/nav.js"></script> <script type="text/javascript" src="../nav/prototype.lite.js"></script> <script type="text/javascript" src="../nav/moo.fx.js"></script> <script type="text/javascript" src="../nav/user_guide_menu.js"></script> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv='expires' content='-1' /> <meta http-equiv= 'pragma' content='no-cache' /> <meta name='robots' content='all' /> <meta name='author' content='Rick Ellis' /> <meta name='description' content='CodeIgniter User Guide' /> </head> <body> <!-- START NAVIGATION --> <div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div> <div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle.jpg" width="153" height="44" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div> <div id="masthead"> <table cellpadding="0" cellspacing="0" border="0" style="width:100%"> <tr> <td><h1>CodeIgniter User Guide Version 1.5.4</h1></td> <td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td> </tr> </table> </div> <!-- END NAVIGATION --> <!-- START BREADCRUMB --> <table cellpadding="0" cellspacing="0" border="0" style="width:100%"> <tr> <td id="breadcrumb"> <a href="http://www.codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp; <a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp; <a href="index.html">Database Library</a> &nbsp;&#8250;&nbsp; Table Data </td> <td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td> </tr> </table> <!-- END BREADCRUMB --> <br clear="all" /> <!-- START CONTENT --> <div id="content"> <h1>Table Data</h1> <p>These functions let you fetch table information.</p> <h2>$this->db->list_tables();</h2> <p>Returns an array containing the names of all the tables in the database you are currently connected to. Example:</p> <code>$tables = $this->db->list_tables();<br /> <br /> foreach ($tables as $table)<br /> {<br /> &nbsp;&nbsp; echo $table;<br /> } </code> <h2>$this->db->table_exists();</h2> <p>Sometimes it's helpful to know whether a particular table exists before running an operation on it. Returns a boolean TRUE/FALSE. Usage example:</p> <code> if ($this->db->table_exists('table_name'))<br /> {<br /> &nbsp;&nbsp; // some code...<br /> } </code> <p>Note: Replace <em>table_name</em> with the name of the table you are looking for.</p> </div> <!-- END CONTENT --> <div id="footer"> <p> Previous Topic:&nbsp;&nbsp;<a href="transactions.html"> Transactions</a> &nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp; <a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp; <a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp; Next Topic:&nbsp;&nbsp;<a href="fields.html"> Field Metadata</a> </p> <p><a href="http://www.codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2007 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">Ellislab, Inc.</a></p> </div> </body> </html> \ No newline at end of file
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html>
+<head>
+
+<title>CodeIgniter User Guide : Table Data</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='Rick Ellis' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle.jpg" width="153" height="44" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://www.codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+<a href="index.html">Database Library</a> &nbsp;&#8250;&nbsp;
+Table Data
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+
+
+<h1>Table Data</h1>
+
+<p>These functions let you fetch table information.</p>
+
+<h2>$this->db->list_tables();</h2>
+
+<p>Returns an array containing the names of all the tables in the database you are currently connected to. Example:</p>
+
+<code>$tables = $this->db->list_tables();<br />
+<br />
+foreach ($tables as $table)<br />
+{<br />
+&nbsp;&nbsp; echo $table;<br />
+}
+</code>
+
+
+<h2>$this->db->table_exists();</h2>
+
+<p>Sometimes it's helpful to know whether a particular table exists before running an operation on it.
+Returns a boolean TRUE/FALSE. Usage example:</p>
+
+<code>
+if ($this->db->table_exists('table_name'))<br />
+{<br />
+&nbsp;&nbsp; // some code...<br />
+}
+</code>
+
+<p>Note: Replace <em>table_name</em> with the name of the table you are looking for.</p>
+
+
+
+
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="transactions.html"> Transactions</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="fields.html"> Field Metadata</a>
+</p>
+<p><a href="http://www.codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2007 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">Ellislab, Inc.</a></p>
+</div>
+
+</body>
+</html> \ No newline at end of file
diff --git a/user_guide/database/transactions.html b/user_guide/database/transactions.html
index 8a9ac1b05..3adf0192c 100644
--- a/user_guide/database/transactions.html
+++ b/user_guide/database/transactions.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/database/utilities.html b/user_guide/database/utilities.html
index 6b6956c88..cdf3f68f5 100644
--- a/user_guide/database/utilities.html
+++ b/user_guide/database/utilities.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
@@ -65,8 +65,6 @@ Database Utility Class
<ul>
<li><a href="#init">Initializing the Utility Class</a></li>
-<li><a href="#create">Creating a Database</a></li>
-<li><a href="#drop">Dropping a Database</a></li>
<li><a href="#list">Listing your Databases</a></li>
<li><a href="#opttb">Optimizing your Tables</a></li>
<li><a href="#repair">Repairing your Databases</a></li>
@@ -77,8 +75,8 @@ Database Utility Class
</ul>
-<a name="init"></a>
-<h2>Initializing the Utility Class</h2>
+
+<h2><a name="init"></a>Initializing the Utility Class</h2>
<p class="important"><strong>Important:</strong>&nbsp; In order to initialize the Utility class, your database driver must
already be running, since the utilities class relies on it.</p>
@@ -91,36 +89,9 @@ already be running, since the utilities class relies on it.</p>
<code>$this->dbutil->some_function()</code>
-
-
-<a name="create"></a>
-<h2>$this->dbutil->create_database('db_name')</h2>
-
-<p>Permits you to create the database specified in the first parameter. Returns TRUE/FALSE based on success or failure:</p>
-
-<code>if ($this->dbutil->create_database('my_db'))<br />
-{<br />
-&nbsp;&nbsp;&nbsp; echo 'Database created!';<br />
-}</code>
-
-
-
-<a name="drop"></a>
-<h2>$this->dbutil->drop_database('db_name')</h2>
-
-<p>Permits you to drop the database specified in the first parameter. Returns TRUE/FALSE based on success or failure:</p>
-
-<code>if ($this->dbutil->drop_database('my_db'))<br />
-{<br />
-&nbsp;&nbsp;&nbsp; echo 'Database deleted!';<br />
-}</code>
-
-
-<a name="list"></a>
-<h2>$this->dbutil->list_databases()</h2>
+<h2><a name="list"></a>$this->dbutil->list_databases()</h2>
<p>Returns an array of database names:</p>
-
<code>
$dbs = $this->dbutil->list_databases();<br />
<br />
@@ -128,10 +99,7 @@ foreach($dbs as $db)<br />
{<br />
&nbsp;&nbsp;&nbsp; echo $db;<br />
}</code>
-
-
-<a name="opttb"></a>
-<h2>$this->dbutil->optimize_table('table_name');</h2>
+<h2><a name="opttb"></a>$this->dbutil->optimize_table('table_name');</h2>
<p class="important"><strong>Note:</strong>&nbsp; This features is only available for MySQL/MySQLi databases.</p>
@@ -148,8 +116,7 @@ if ($this->dbutil->optimize_table('table_name'))<br />
<p><strong>Note:</strong> Not all database platforms support table optimization.</p>
-<a name="repair"></a>
-<h2>$this->dbutil->repair_table('table_name');</h2>
+<h2><a name="repair"></a>$this->dbutil->repair_table('table_name');</h2>
<p class="important"><strong>Note:</strong>&nbsp; This features is only available for MySQL/MySQLi databases.</p>
@@ -166,8 +133,7 @@ if ($this->dbutil->repair_table('table_name'))<br />
<p><strong>Note:</strong> Not all database platforms support table repairs.</p>
-<a name="optdb"></a>
-<h2>$this->dbutil->optimize_database();</h2>
+<h2><a name="optdb"></a>$this->dbutil->optimize_database();</h2>
<p class="important"><strong>Note:</strong>&nbsp; This features is only available for MySQL/MySQLi databases.</p>
@@ -185,8 +151,7 @@ if ($result !== FALSE)<br />
<p><strong>Note:</strong> Not all database platforms support table optimization.</p>
-<a name="csv"></a>
-<h2>$this->dbutil->csv_from_result($db_result)</h2>
+<h2><a name="csv"></a>$this->dbutil->csv_from_result($db_result)</h2>
<p>Permits you to generate a CSV file from a query result. The first parameter of the function must contain the result object from your query.
Example:</p>
@@ -213,8 +178,7 @@ echo $this->dbutil->csv_from_result($query, $delimiter, $newline);
If you need to write the file use the <a href="../helpers/file_helper.html">File Helper</a>.</p>
-<a name="xml"></a>
-<h2>$this->dbutil->xml_from_result($db_result)</h2>
+<h2><a name="xml"></a>$this->dbutil->xml_from_result($db_result)</h2>
<p>Permits you to generate an XML file from a query result. The first parameter expects a query result object, the second
may contain an optional array of config parameters. Example:</p>
@@ -238,8 +202,7 @@ echo $this->dbutil->xml_from_result($query, $config);
If you need to write the file use the <a href="../helpers/file_helper.html">File Helper</a>.</p>
-<a name="backup"></a>
-<h2>$this->dbutil->backup()</h2>
+<h2><a name="backup"></a>$this->dbutil->backup()</h2>
<p>Permits you to backup your full database or individual tables. The backup data can be compressed in either Zip or Gzip format.</p>
@@ -320,12 +283,11 @@ $this->dbutil->backup($prefs);
<div id="footer">
<p>
-Previous Topic:&nbsp;&nbsp;<a href="caching.html">DB Caching Class</a>
+Previous Topic:&nbsp;&nbsp;<a href="forge.html">DB Forge Class</a>
&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
-Next Topic:&nbsp;&nbsp;<a href="../libraries/email.html"> Email Class</a>
-</p>
+Next Topic:&nbsp;&nbsp;<a href="../libraries/email.html"> Email Class</a></p>
<p><a href="http://www.codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2007 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">Ellislab, Inc.</a></p>
</div>
diff --git a/user_guide/general/alternative_php.html b/user_guide/general/alternative_php.html
index b5a9d6950..1db172741 100644
--- a/user_guide/general/alternative_php.html
+++ b/user_guide/general/alternative_php.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/general/ancillary_classes.html b/user_guide/general/ancillary_classes.html
index 5398d85fb..84869083e 100644
--- a/user_guide/general/ancillary_classes.html
+++ b/user_guide/general/ancillary_classes.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/general/autoloader.html b/user_guide/general/autoloader.html
index 5af8be10f..0ece5b01f 100644
--- a/user_guide/general/autoloader.html
+++ b/user_guide/general/autoloader.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/general/caching.html b/user_guide/general/caching.html
index 959994f06..67b1dd857 100644
--- a/user_guide/general/caching.html
+++ b/user_guide/general/caching.html
@@ -1 +1,115 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>CodeIgniter User Guide : Web Page Caching</title> <style type='text/css' media='all'>@import url('../userguide.css');</style> <link rel='stylesheet' type='text/css' media='all' href='../userguide.css' /> <script type="text/javascript" src="../nav/nav.js"></script> <script type="text/javascript" src="../nav/prototype.lite.js"></script> <script type="text/javascript" src="../nav/moo.fx.js"></script> <script type="text/javascript" src="../nav/user_guide_menu.js"></script> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv='expires' content='-1' /> <meta http-equiv= 'pragma' content='no-cache' /> <meta name='robots' content='all' /> <meta name='author' content='Rick Ellis' /> <meta name='description' content='CodeIgniter User Guide' /> </head> <body> <!-- START NAVIGATION --> <div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div> <div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle.jpg" width="153" height="44" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div> <div id="masthead"> <table cellpadding="0" cellspacing="0" border="0" style="width:100%"> <tr> <td><h1>CodeIgniter User Guide Version 1.5.4</h1></td> <td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td> </tr> </table> </div> <!-- END NAVIGATION --> <!-- START BREADCRUMB --> <table cellpadding="0" cellspacing="0" border="0" style="width:100%"> <tr> <td id="breadcrumb"> <a href="http://www.codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp; <a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp; Page Caching </td> <td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td> </tr> </table> <!-- END BREADCRUMB --> <br clear="all" /> <!-- START CONTENT --> <div id="content"> <h1>Web Page Caching</h1> <p>CodeIgniter lets you cache your pages in order to achieve maximum performance.</p> <p>Although CodeIgniter is quite fast, the amount of dynamic information you display in your pages will correlate directly to the server resources, memory, and processing cycles utilized, which affect your page load speeds. By caching your pages, since they are saved in their fully rendered state, you can achieve performance that nears that of static web pages.</p> <h2>How Does Caching Work?</h2> <p>Caching can be enabled on a per-page basis, and you can set the length of time that a page should remain cached before being refreshed. When a page is loaded for the first time, the cache file will be written to your <dfn>system/cache</dfn> folder. On subsequent page loads the cache file will be retrieved and sent to the requesting user's browser. If it has expired, it will be deleted and refreshed before being sent to the browser.</p> <p>Note: The Benchmark tag is not cached so you can still view your page load speed when caching is enabled.</p> <h2>Enabling Caching</h2> <p>To enable caching, put the following tag in any of your controller functions:</p> <code>$this->output->cache(<var>n</var>);</code> <p>Where <var>n</var> is the number of <strong>minutes</strong> you wish the page to remain cached between refreshes.</p> <p>The above tag can go anywhere within a function. It is not affected by the order that it appears, so place it wherever it seems most logical to you. Once the tag is in place, your pages will begin being cached.</p> <p class="important"><strong>Warning:</strong> Because of the way CodeIgniter stores content for output, caching will only work if you are generating display for your controller with a <a href="./views.html">view</a>.</p> <p class="important"><strong>Note:</strong> Before the cache files can be written you must set the file permissions on your <dfn>system/cache</dfn> folder such that it is writable.</p> <h2>Deleting Caches</h2> <p>If you no longer wish to cache a file you can remove the caching tag and it will no longer be refreshed when it expires. Note: Removing the tag will not delete the cache immediately. It will have to expire normally. If you need to remove it earlier you will need to manually delete it from your cache folder.</p> </div> <!-- END CONTENT --> <div id="footer"> <p> Previous Topic:&nbsp;&nbsp;<a href="errors.html">Error Handling</a> &nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp; <a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp; <a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp; Next Topic:&nbsp;&nbsp;<a href="profiling.html">Profiling Your Application</a> </p> <p><a href="http://www.codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2007 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">Ellislab, Inc.</a></p> </div> </body> </html> \ No newline at end of file
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html>
+<head>
+
+<title>CodeIgniter User Guide : Web Page Caching</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='Rick Ellis' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle.jpg" width="153" height="44" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://www.codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Page Caching
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+
+<h1>Web Page Caching</h1>
+
+<p>CodeIgniter lets you cache your pages in order to achieve maximum performance.</p>
+
+<p>Although CodeIgniter is quite fast, the amount of dynamic information you display in your pages will correlate directly to the
+server resources, memory, and processing cycles utilized, which affect your page load speeds.
+By caching your pages, since they are saved in their fully rendered state, you can achieve performance that nears that of static web pages.</p>
+
+
+<h2>How Does Caching Work?</h2>
+
+<p>Caching can be enabled on a per-page basis, and you can set the length of time that a page should remain cached before being refreshed.
+When a page is loaded for the first time, the cache file will be written to your <dfn>system/cache</dfn> folder. On subsequent page loads the cache file will be retrieved
+and sent to the requesting user's browser. If it has expired, it will be deleted and refreshed before being sent to the browser.</p>
+
+<p>Note: The Benchmark tag is not cached so you can still view your page load speed when caching is enabled.</p>
+
+<h2>Enabling Caching</h2>
+
+<p>To enable caching, put the following tag in any of your controller functions:</p>
+
+<code>$this->output->cache(<var>n</var>);</code>
+
+<p>Where <var>n</var> is the number of <strong>minutes</strong> you wish the page to remain cached between refreshes.</p>
+
+<p>The above tag can go anywhere within a function. It is not affected by the order that it appears, so place it wherever it seems
+most logical to you. Once the tag is in place, your pages will begin being cached.</p>
+
+<p class="important"><strong>Warning:</strong> Because of the way CodeIgniter stores content for output, caching will only work if you are generating display for your controller with a <a href="./views.html">view</a>.</p>
+<p class="important"><strong>Note:</strong> Before the cache files can be written you must set the file permissions on your
+<dfn>system/cache</dfn> folder such that it is writable.</p>
+
+<h2>Deleting Caches</h2>
+
+<p>If you no longer wish to cache a file you can remove the caching tag and it will no longer be refreshed when it expires. Note:
+Removing the tag will not delete the cache immediately. It will have to expire normally. If you need to remove it earlier you
+will need to manually delete it from your cache folder.</p>
+
+
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="errors.html">Error Handling</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="profiling.html">Profiling Your Application</a>
+</p>
+<p><a href="http://www.codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2007 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">Ellislab, Inc.</a></p>
+</div>
+
+</body>
+</html> \ No newline at end of file
diff --git a/user_guide/general/controllers.html b/user_guide/general/controllers.html
index f94262129..b85c6e14e 100644
--- a/user_guide/general/controllers.html
+++ b/user_guide/general/controllers.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/general/core_classes.html b/user_guide/general/core_classes.html
index 870ff8c32..b284e4f69 100644
--- a/user_guide/general/core_classes.html
+++ b/user_guide/general/core_classes.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/general/creating_libraries.html b/user_guide/general/creating_libraries.html
index f5e12f8fb..d489963b5 100644
--- a/user_guide/general/creating_libraries.html
+++ b/user_guide/general/creating_libraries.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/general/credits.html b/user_guide/general/credits.html
index 99a670c8e..48a705c51 100644
--- a/user_guide/general/credits.html
+++ b/user_guide/general/credits.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/general/errors.html b/user_guide/general/errors.html
index 6dc061f69..9da97b416 100644
--- a/user_guide/general/errors.html
+++ b/user_guide/general/errors.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/general/helpers.html b/user_guide/general/helpers.html
index 8c4f69571..0ac71075d 100644
--- a/user_guide/general/helpers.html
+++ b/user_guide/general/helpers.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/general/hooks.html b/user_guide/general/hooks.html
index 96b6bc691..7e564baec 100644
--- a/user_guide/general/hooks.html
+++ b/user_guide/general/hooks.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/general/index.html b/user_guide/general/index.html
index 40fb40d70..e5d0f1103 100644
--- a/user_guide/general/index.html
+++ b/user_guide/general/index.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/general/libraries.html b/user_guide/general/libraries.html
index 3e2f9d354..24b47a5e4 100644
--- a/user_guide/general/libraries.html
+++ b/user_guide/general/libraries.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/general/managing_apps.html b/user_guide/general/managing_apps.html
index e22114ae0..747b5f39b 100644
--- a/user_guide/general/managing_apps.html
+++ b/user_guide/general/managing_apps.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/general/models.html b/user_guide/general/models.html
index 90f895538..cfeefacab 100644
--- a/user_guide/general/models.html
+++ b/user_guide/general/models.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/general/plugins.html b/user_guide/general/plugins.html
index 6fd755868..5b84d7a4a 100644
--- a/user_guide/general/plugins.html
+++ b/user_guide/general/plugins.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/general/profiling.html b/user_guide/general/profiling.html
index 9eb6f1b46..ebcdb41b7 100644
--- a/user_guide/general/profiling.html
+++ b/user_guide/general/profiling.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/general/quick_reference.html b/user_guide/general/quick_reference.html
index d93d646cd..b57673c59 100644
--- a/user_guide/general/quick_reference.html
+++ b/user_guide/general/quick_reference.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/general/requirements.html b/user_guide/general/requirements.html
index 74952d755..1849ddaa1 100644
--- a/user_guide/general/requirements.html
+++ b/user_guide/general/requirements.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/general/routing.html b/user_guide/general/routing.html
index f7f93c838..88e13ff67 100644
--- a/user_guide/general/routing.html
+++ b/user_guide/general/routing.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/general/scaffolding.html b/user_guide/general/scaffolding.html
index 48d1b193e..25f20a5dc 100644
--- a/user_guide/general/scaffolding.html
+++ b/user_guide/general/scaffolding.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/general/security.html b/user_guide/general/security.html
index 843b6c586..8c9c6c8c7 100644
--- a/user_guide/general/security.html
+++ b/user_guide/general/security.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/general/urls.html b/user_guide/general/urls.html
index 48c4a1ff5..c8e3c6720 100644
--- a/user_guide/general/urls.html
+++ b/user_guide/general/urls.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/general/views.html b/user_guide/general/views.html
index 1bcaf4193..eba45738f 100644
--- a/user_guide/general/views.html
+++ b/user_guide/general/views.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/helpers/array_helper.html b/user_guide/helpers/array_helper.html
index 136d475af..8dd8cc794 100644
--- a/user_guide/helpers/array_helper.html
+++ b/user_guide/helpers/array_helper.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/helpers/cookie_helper.html b/user_guide/helpers/cookie_helper.html
index 46307d18d..f902592c4 100644
--- a/user_guide/helpers/cookie_helper.html
+++ b/user_guide/helpers/cookie_helper.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/helpers/date_helper.html b/user_guide/helpers/date_helper.html
index 7b91d8806..ea2612e29 100644
--- a/user_guide/helpers/date_helper.html
+++ b/user_guide/helpers/date_helper.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/helpers/directory_helper.html b/user_guide/helpers/directory_helper.html
index d739778b1..c3b35c56b 100644
--- a/user_guide/helpers/directory_helper.html
+++ b/user_guide/helpers/directory_helper.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/helpers/download_helper.html b/user_guide/helpers/download_helper.html
index dd644e540..55f13db02 100644
--- a/user_guide/helpers/download_helper.html
+++ b/user_guide/helpers/download_helper.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/helpers/file_helper.html b/user_guide/helpers/file_helper.html
index da8337cb1..646956cd5 100644
--- a/user_guide/helpers/file_helper.html
+++ b/user_guide/helpers/file_helper.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/helpers/form_helper.html b/user_guide/helpers/form_helper.html
index 62c1f68f3..bc9c8902d 100644
--- a/user_guide/helpers/form_helper.html
+++ b/user_guide/helpers/form_helper.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/helpers/html_helper.html b/user_guide/helpers/html_helper.html
index 8dc3f0060..564f4e6f2 100644
--- a/user_guide/helpers/html_helper.html
+++ b/user_guide/helpers/html_helper.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/helpers/index.html b/user_guide/helpers/index.html
index 41526906d..2946641ce 100644
--- a/user_guide/helpers/index.html
+++ b/user_guide/helpers/index.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/helpers/inflector_helper.html b/user_guide/helpers/inflector_helper.html
index e19eaec5e..917e0cc77 100644
--- a/user_guide/helpers/inflector_helper.html
+++ b/user_guide/helpers/inflector_helper.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/helpers/security_helper.html b/user_guide/helpers/security_helper.html
index 0c9f7b92c..6032d68cb 100644
--- a/user_guide/helpers/security_helper.html
+++ b/user_guide/helpers/security_helper.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/helpers/smiley_helper.html b/user_guide/helpers/smiley_helper.html
index 715c3df4f..c9b86c825 100644
--- a/user_guide/helpers/smiley_helper.html
+++ b/user_guide/helpers/smiley_helper.html
@@ -1 +1,204 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>CodeIgniter User Guide : Smiley Helper</title> <style type='text/css' media='all'>@import url('../userguide.css');</style> <link rel='stylesheet' type='text/css' media='all' href='../userguide.css' /> <script type="text/javascript" src="../nav/nav.js"></script> <script type="text/javascript" src="../nav/prototype.lite.js"></script> <script type="text/javascript" src="../nav/moo.fx.js"></script> <script type="text/javascript" src="../nav/user_guide_menu.js"></script> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv='expires' content='-1' /> <meta http-equiv= 'pragma' content='no-cache' /> <meta name='robots' content='all' /> <meta name='author' content='Rick Ellis' /> <meta name='description' content='CodeIgniter User Guide' /> </head> <body> <!-- START NAVIGATION --> <div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div> <div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle.jpg" width="153" height="44" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div> <div id="masthead"> <table cellpadding="0" cellspacing="0" border="0" style="width:100%"> <tr> <td><h1>CodeIgniter User Guide Version 1.5.4</h1></td> <td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td> </tr> </table> </div> <!-- END NAVIGATION --> <!-- START BREADCRUMB --> <table cellpadding="0" cellspacing="0" border="0" style="width:100%"> <tr> <td id="breadcrumb"> <a href="http://www.codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp; <a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp; Smiley Helper </td> <td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td> </tr> </table> <!-- END BREADCRUMB --> <br clear="all" /> <!-- START CONTENT --> <div id="content"> <h1>Smiley Helper</h1> <p>The Smiley Helper file contains functions that let you manage smileys (emoticons).</p> <h2>Loading this Helper</h2> <p>This helper is loaded using the following code:</p> <code>$this->load->helper('smiley');</code> <h2>Overview</h2> <p>The Smiley helper has a renderer that takes plain text simileys, like <dfn>:-)</dfn> and turns them into a image representation, like <img src="../images/smile.gif" width="19" height="19" border="0" alt="smile!" /></p> <p>It also lets you display a set of smiley images that when clicked will be inserted into a form field. For example, if you have a blog that allows user commenting you can show the smileys next to the comment form. Your users can click a desired smiley and with the help of some JavaScript it will be placed into the form field.</p> <h2>Clickable Smileys Tutorial</h2> <p>Here is an example demonstrating how you might create a set of clickable smileys next to a form field. This example requires that you first download and install the smiley images, then create a controller and the View as described.</p> <p class="important"><strong>Important:</strong> Before you begin, please <a href="http://www.codeigniter.com/downloads/smileys.zip">download the smiley images</a> and put them in a publicly accessible place on your server. This helper also assumes you have the smiley replacement array located at <dfn>application/config/smileys.php</dfn></p> <h3>The Controller</h3> <p>In your <dfn>application/controllers/</dfn> folder, create a file called <kbd>smileys.php</kbd> and place the code below in it.</p> <p><strong>Important:</strong> Change the URL in the <dfn>get_clickable_smileys()</dfn> function below so that it points to your <dfn>smiley</dfn> folder.</p> <p>You'll notice that in addition to the smiley helper we are using the <a href="../libraries/table.html">Table Class</a>.</p> <textarea class="textarea" style="width:100%" cols="50" rows="25"> <?php class Smileys extends Controller { function Smileys() { parent::Controller(); } function index() { $this->load->helper('smiley'); $this->load->library('table'); $image_array = get_clickable_smileys('http://www.your-site.com/images/smileys/'); $col_array = $this->table->make_columns($image_array, 8); $data['smiley_table'] = $this->table->generate($col_array); $this->load->view('smiley_view', $data); } } ?> </textarea> <p>In your <dfn>application/views/</dfn> folder, create a file called <kbd>smiley_view.php</kbd> and place this code in it:</p> <textarea class="textarea" style="width:100%" cols="50" rows="20"> &lt;html> &lt;head> &lt;title>Smileys&lt;/title> &lt;?php echo js_insert_smiley('blog', 'comments'); ?> &lt;/head> &lt;body> &lt;form name="blog"> &lt;textarea name="comments" cols="40" rows="4">&lt;/textarea> &lt;/form> &lt;p>Click to insert a smiley!&lt;/p> &lt;?php echo $smiley_table; ?> &lt;/body> &lt;/html> </textarea> <p>When you have created the above controller and view, load it by visiting <dfn>http://www.your=site.com/index.php/smileys/</dfn></p> <h1>Function Reference</h1> <h2>get_clickable_smileys()</h2> <p>Returns an array containing your smiley images wrapped in a cliackable link. You must supply the URL to your smiley folder via the first parameter:</p> <code>$image_array = get_clickable_smileys("http://www.your-site.com/images/smileys/");</code> <h2>js_insert_smiley()</h2> <p>Generates the JavaScript that allows the images to be clicked and inserted into a form field. The first parameter must contain the name of your form, the second parameter must contain the name of the form field. This function is designed to be placed into the &lt;head&gt; area of your web page.</p> <code>&lt;?php echo js_insert_smiley('blog', 'comments'); ?&gt;</code> <h2>parse_smileys()</h2> <p>Takes a string of text as input and replaces any contained plain text smileys into the image equivalent. The first parameter must contain your string, the second must contain the the URL to your smiley folder:</p> <code> $str = 'Here are some simileys: :-) ;-)'; $str = parse_smileys($str, "http://www.your-site.com/images/smileys/"); echo $str; </code> </div> <!-- END CONTENT --> <div id="footer"> <p> Previous Topic:&nbsp;&nbsp;<a href="security_helper.html">Security Helper</a> &nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp; <a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp; <a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp; Next Topic:&nbsp;&nbsp;<a href="string_helper.html">String Helper</a> </p> <p><a href="http://www.codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2007 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">Ellislab, Inc.</a></p> </div> </body> </html> \ No newline at end of file
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html>
+<head>
+
+<title>CodeIgniter User Guide : Smiley Helper</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='Rick Ellis' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle.jpg" width="153" height="44" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://www.codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Smiley Helper
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+
+<h1>Smiley Helper</h1>
+
+<p>The Smiley Helper file contains functions that let you manage smileys (emoticons).</p>
+
+
+<h2>Loading this Helper</h2>
+
+<p>This helper is loaded using the following code:</p>
+<code>$this->load->helper('smiley');</code>
+
+<h2>Overview</h2>
+
+<p>The Smiley helper has a renderer that takes plain text simileys, like <dfn>:-)</dfn> and turns
+them into a image representation, like <img src="../images/smile.gif" width="19" height="19" border="0" alt="smile!" /></p>
+
+<p>It also lets you display a set of smiley images that when clicked will be inserted into a form field.
+For example, if you have a blog that allows user commenting you can show the smileys next to the comment form.
+Your users can click a desired smiley and with the help of some JavaScript it will be placed into the form field.</p>
+
+
+
+<h2>Clickable Smileys Tutorial</h2>
+
+<p>Here is an example demonstrating how you might create a set of clickable smileys next to a form field. This example
+requires that you first download and install the smiley images, then create a controller and the View as described.</p>
+
+<p class="important"><strong>Important:</strong> Before you begin, please <a href="http://www.codeigniter.com/downloads/smileys.zip">download the smiley images</a> and put them in
+a publicly accessible place on your server. This helper also assumes you have the smiley replacement array located at
+<dfn>application/config/smileys.php</dfn></p>
+
+
+<h3>The Controller</h3>
+
+<p>In your <dfn>application/controllers/</dfn> folder, create a file called <kbd>smileys.php</kbd> and place the code below in it.</p>
+
+<p><strong>Important:</strong> Change the URL in the <dfn>get_clickable_smileys()</dfn> function below so that it points to
+your <dfn>smiley</dfn> folder.</p>
+
+<p>You'll notice that in addition to the smiley helper we are using the <a href="../libraries/table.html">Table Class</a>.</p>
+
+<textarea class="textarea" style="width:100%" cols="50" rows="25">
+<?php
+
+class Smileys extends Controller {
+
+ function Smileys()
+ {
+ parent::Controller();
+ }
+
+ function index()
+ {
+ $this->load->helper('smiley');
+ $this->load->library('table');
+
+ $image_array = get_clickable_smileys('http://www.your-site.com/images/smileys/');
+
+ $col_array = $this->table->make_columns($image_array, 8);
+
+ $data['smiley_table'] = $this->table->generate($col_array);
+
+ $this->load->view('smiley_view', $data);
+ }
+
+}
+?>
+</textarea>
+
+<p>In your <dfn>application/views/</dfn> folder, create a file called <kbd>smiley_view.php</kbd> and place this code in it:</p>
+
+
+<textarea class="textarea" style="width:100%" cols="50" rows="20">
+&lt;html>
+&lt;head>
+&lt;title>Smileys&lt;/title>
+
+&lt;?php echo js_insert_smiley('blog', 'comments'); ?>
+
+&lt;/head>
+&lt;body>
+
+&lt;form name="blog">
+&lt;textarea name="comments" cols="40" rows="4">&lt;/textarea>
+&lt;/form>
+
+&lt;p>Click to insert a smiley!&lt;/p>
+
+&lt;?php echo $smiley_table; ?>
+
+&lt;/body>
+&lt;/html>
+</textarea>
+
+
+<p>When you have created the above controller and view, load it by visiting <dfn>http://www.your=site.com/index.php/smileys/</dfn></p>
+
+<h1>Function Reference</h1>
+
+
+<h2>get_clickable_smileys()</h2>
+
+<p>Returns an array containing your smiley images wrapped in a cliackable link. You must supply the URL to your smiley folder
+via the first parameter:</p>
+
+<code>$image_array = get_clickable_smileys("http://www.your-site.com/images/smileys/");</code>
+
+
+<h2>js_insert_smiley()</h2>
+
+<p>Generates the JavaScript that allows the images to be clicked and inserted into a form field.
+The first parameter must contain the name of your form, the second parameter must contain the name of the
+form field. This function is designed to be placed into the &lt;head&gt; area of your web page.</p>
+
+<code>&lt;?php echo js_insert_smiley('blog', 'comments'); ?&gt;</code>
+
+
+<h2>parse_smileys()</h2>
+
+<p>Takes a string of text as input and replaces any contained plain text smileys into the image
+equivalent. The first parameter must contain your string, the second must contain the the URL to your smiley folder:</p>
+
+<code>
+
+$str = 'Here are some simileys: :-) ;-)';
+
+$str = parse_smileys($str, "http://www.your-site.com/images/smileys/");
+
+echo $str;
+</code>
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="security_helper.html">Security Helper</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="string_helper.html">String Helper</a>
+</p>
+<p><a href="http://www.codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2007 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">Ellislab, Inc.</a></p>
+</div>
+
+</body>
+</html> \ No newline at end of file
diff --git a/user_guide/helpers/string_helper.html b/user_guide/helpers/string_helper.html
index 554afc824..74be2306d 100644
--- a/user_guide/helpers/string_helper.html
+++ b/user_guide/helpers/string_helper.html
@@ -1 +1,176 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>CodeIgniter User Guide : String Helper</title> <style type='text/css' media='all'>@import url('../userguide.css');</style> <link rel='stylesheet' type='text/css' media='all' href='../userguide.css' /> <script type="text/javascript" src="../nav/nav.js"></script> <script type="text/javascript" src="../nav/prototype.lite.js"></script> <script type="text/javascript" src="../nav/moo.fx.js"></script> <script type="text/javascript" src="../nav/user_guide_menu.js"></script> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv='expires' content='-1' /> <meta http-equiv= 'pragma' content='no-cache' /> <meta name='robots' content='all' /> <meta name='author' content='Rick Ellis' /> <meta name='description' content='CodeIgniter User Guide' /> </head> <body> <!-- START NAVIGATION --> <div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div> <div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle.jpg" width="153" height="44" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div> <div id="masthead"> <table cellpadding="0" cellspacing="0" border="0" style="width:100%"> <tr> <td><h1>CodeIgniter User Guide Version 1.5.4</h1></td> <td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td> </tr> </table> </div> <!-- END NAVIGATION --> <!-- START BREADCRUMB --> <table cellpadding="0" cellspacing="0" border="0" style="width:100%"> <tr> <td id="breadcrumb"> <a href="http://www.codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp; <a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp; String Helper </td> <td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td> </tr> </table> <!-- END BREADCRUMB --> <br clear="all" /> <!-- START CONTENT --> <div id="content"> <h1>String Helper</h1> <p>The String Helper file contains functions that assist in working with strings.</p> <h2>Loading this Helper</h2> <p>This helper is loaded using the following code:</p> <code>$this->load->helper('string');</code> <p>The following functions are available:</p> <h2>random_string()</h2> <p>Generates a random string based on the type and length you specify. Useful for creating passwords or generating random hashes.</p> <p>The first parameter specifies the type of string, the second parameter specifies the length. The following choices are available:</p> <ul> <li><strong>alnum</strong>:&nbsp; Alpha-numeric string with lower and uppercase characters.</li> <li><strong>numeric</strong>:&nbsp; Numeric string.</li> <li><strong>nozero</strong>:&nbsp; Numeric string with no zeros.</li> <li><strong>unique</strong>:&nbsp; Encrypted with MD5 and uniqid(). Note: The length parameter is not available for this type. Returns a fixed length 33 character string.</li> </ul> <p>Usage example:</p> <code>echo random_string('alnum', 16);</code> <h2>alternator()</h2> <p>Allows two or more items to be alternated between, when cycling through a loop. Example:</p> <code>for ($i = 0; $i < 10; $i++)<br /> {<br /> &nbsp;&nbsp;&nbsp;&nbsp;echo alternator('string one', 'string two');<br /> }<br /> </code> <p>You can add as many parameters as you want, and with each iteration of your loop the next item will be returned.</p> <code>for ($i = 0; $i < 10; $i++)<br /> {<br /> &nbsp;&nbsp;&nbsp;&nbsp;echo alternator('one', 'two', 'three', 'four', 'five');<br /> }<br /> </code> <p><strong>Note:</strong> To use multiple separate calls to this function simply call the function with no arguments to re-initialize.</p> <h2>repeater()</h2> <p>Generates repeating copies of the data you submit. Example:</p> <code>$string = "\n";<br /> echo repeater($string, 30);</code> <p>The above would generate 30 newlines.</p> <h2>reduce_double_slashes()</h2> <p>Converts double slashes in a string to a single slash, except those found in http://. Example: </p> <code>$string = &quot;http://www.example.com//index.php&quot;;<br /> echo reduce_double_slashes($string); // results in &quot;http://www.example.com/index.php&quot;</code> <h2>trim_slashes()</h2> <p>Removes any leading/trailing slashes from a string. Example:<br /> <br /> <code>$string = &quot;/this/that/theother/&quot;;<br /> echo trim_slashes($string); // results in this/that/theother</code></p> <h2>reduce_multiples()</h2> <p>Reduces multiple instances of a particular character occuring directly after each other. Example:</p> <code> $string="Fred, Bill,, Joe, Jimmy";<br /> $string=reduce_multiples($string,","); //results in "Fred, Bill, Joe, Jimmy" </code> <p>The function accepts the following parameters: <code>reduce_multiples(string: text to search in, string: character to reduce, boolean: whether to remove the character from the front and end of the string)</code> The first parameter contrains the string in which you want to reduce the multiplies. The second parameter contains the character you want to have reduced. The third parameter is False by default. If it it's to true it will remove occurences of the character at the beginning and the end of the string. Example: <code> $string=",Fred, Bill,, Joe, Jimmy,";<br /> $string=reduce_multiples($string,",",true); //results in "Fred, Bill, Joe, Jimmy" </code> </p> <h2>quotes_to_entities()</h2> <p>Converts single and double quotes in a string to the corresponding HTML entities. Example:</p> <code>$string="Joe's \"dinner\"";<br /> $string=quotes_to_entities($string); //results in "Joe&amp;#39;s &amp;quot;dinner&amp;quot;" </code> <h2>strip_quotes()</h2> <p>Removes single and double quotes from a string. Example:</p> <code>$string="Joe's \"dinner\"";<br /> $string=strip_quotes($string); //results in "Joes dinner" </code> </div> <!-- END CONTENT --> <div id="footer"> <p> Previous Topic:&nbsp;&nbsp;<a href="smiley_helper.html">Smiley Helper</a> &nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp; <a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp; <a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp; Next Topic:&nbsp;&nbsp;<a href="text_helper.html">Text Helper</a> </p> <p><a href="http://www.codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2007 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">Ellislab, Inc.</a></p> </div> </body> </html> \ No newline at end of file
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html>
+<head>
+
+<title>CodeIgniter User Guide : String Helper</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='Rick Ellis' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle.jpg" width="153" height="44" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://www.codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+String Helper
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+
+<h1>String Helper</h1>
+
+<p>The String Helper file contains functions that assist in working with strings.</p>
+
+
+<h2>Loading this Helper</h2>
+
+<p>This helper is loaded using the following code:</p>
+<code>$this->load->helper('string');</code>
+
+<p>The following functions are available:</p>
+
+<h2>random_string()</h2>
+
+<p>Generates a random string based on the type and length you specify. Useful for creating passwords or generating random hashes.</p>
+
+<p>The first parameter specifies the type of string, the second parameter specifies the length. The following choices are available:</p>
+
+
+<ul>
+<li><strong>alnum</strong>:&nbsp; Alpha-numeric string with lower and uppercase characters.</li>
+<li><strong>numeric</strong>:&nbsp; Numeric string.</li>
+<li><strong>nozero</strong>:&nbsp; Numeric string with no zeros.</li>
+<li><strong>unique</strong>:&nbsp; Encrypted with MD5 and uniqid(). Note: The length parameter is not available for this type.
+Returns a fixed length 33 character string.</li>
+</ul>
+
+<p>Usage example:</p>
+
+<code>echo random_string('alnum', 16);</code>
+
+
+<h2>alternator()</h2>
+
+<p>Allows two or more items to be alternated between, when cycling through a loop. Example:</p>
+
+<code>for ($i = 0; $i < 10; $i++)<br />
+{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;echo alternator('string one', 'string two');<br />
+}<br />
+</code>
+
+<p>You can add as many parameters as you want, and with each iteration of your loop the next item will be returned.</p>
+
+<code>for ($i = 0; $i < 10; $i++)<br />
+{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;echo alternator('one', 'two', 'three', 'four', 'five');<br />
+}<br />
+</code>
+
+<p><strong>Note:</strong> To use multiple separate calls to this function simply call the function with no arguments to re-initialize.</p>
+
+
+
+<h2>repeater()</h2>
+<p>Generates repeating copies of the data you submit. Example:</p>
+<code>$string = "\n";<br />
+echo repeater($string, 30);</code>
+
+<p>The above would generate 30 newlines.</p>
+<h2>reduce_double_slashes()</h2>
+<p>Converts double slashes in a string to a single slash, except those found in http://. Example: </p>
+<code>$string = &quot;http://www.example.com//index.php&quot;;<br />
+echo reduce_double_slashes($string); // results in &quot;http://www.example.com/index.php&quot;</code>
+<h2>trim_slashes()</h2>
+<p>Removes any leading/trailing slashes from a string. Example:<br />
+ <br />
+ <code>$string = &quot;/this/that/theother/&quot;;<br />
+echo trim_slashes($string); // results in this/that/theother</code></p>
+
+
+<h2>reduce_multiples()</h2>
+<p>Reduces multiple instances of a particular character occuring directly after each other. Example:</p>
+<code>
+$string="Fred, Bill,, Joe, Jimmy";<br />
+$string=reduce_multiples($string,","); //results in "Fred, Bill, Joe, Jimmy"
+</code>
+<p>The function accepts the following parameters:
+<code>reduce_multiples(string: text to search in, string: character to reduce, boolean: whether to remove the character from the front and end of the string)</code>
+
+The first parameter contrains the string in which you want to reduce the multiplies. The second parameter contains the character you want to have reduced.
+The third parameter is False by default. If it it's to true it will remove occurences of the character at the beginning and the end of the string. Example:
+
+<code>
+$string=",Fred, Bill,, Joe, Jimmy,";<br />
+$string=reduce_multiples($string,",",true); //results in "Fred, Bill, Joe, Jimmy"
+</code>
+</p>
+
+<h2>quotes_to_entities()</h2>
+<p>Converts single and double quotes in a string to the corresponding HTML entities. Example:</p>
+<code>$string="Joe's \"dinner\"";<br />
+$string=quotes_to_entities($string); //results in "Joe&amp;#39;s &amp;quot;dinner&amp;quot;"
+</code>
+
+<h2>strip_quotes()</h2>
+<p>Removes single and double quotes from a string. Example:</p>
+<code>$string="Joe's \"dinner\"";<br />
+$string=strip_quotes($string); //results in "Joes dinner"
+</code>
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="smiley_helper.html">Smiley Helper</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="text_helper.html">Text Helper</a>
+</p>
+<p><a href="http://www.codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2007 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">Ellislab, Inc.</a></p>
+</div>
+
+</body>
+</html> \ No newline at end of file
diff --git a/user_guide/helpers/text_helper.html b/user_guide/helpers/text_helper.html
index 7a83d8f9a..217689c48 100644
--- a/user_guide/helpers/text_helper.html
+++ b/user_guide/helpers/text_helper.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/helpers/typography_helper.html b/user_guide/helpers/typography_helper.html
index 686f5c23e..e3d18f8fb 100644
--- a/user_guide/helpers/typography_helper.html
+++ b/user_guide/helpers/typography_helper.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/helpers/url_helper.html b/user_guide/helpers/url_helper.html
index f2c45c343..854d06a23 100644
--- a/user_guide/helpers/url_helper.html
+++ b/user_guide/helpers/url_helper.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/helpers/xml_helper.html b/user_guide/helpers/xml_helper.html
index 6336eec53..47082a59f 100644
--- a/user_guide/helpers/xml_helper.html
+++ b/user_guide/helpers/xml_helper.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/index.html b/user_guide/index.html
index e944de712..69c90fc04 100644
--- a/user_guide/index.html
+++ b/user_guide/index.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/installation/downloads.html b/user_guide/installation/downloads.html
index f93b89778..1104f8ba7 100644
--- a/user_guide/installation/downloads.html
+++ b/user_guide/installation/downloads.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/installation/index.html b/user_guide/installation/index.html
index 299f73e87..c31c66153 100644
--- a/user_guide/installation/index.html
+++ b/user_guide/installation/index.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/installation/troubleshooting.html b/user_guide/installation/troubleshooting.html
index 40b7e36c6..ceff6a52f 100644
--- a/user_guide/installation/troubleshooting.html
+++ b/user_guide/installation/troubleshooting.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/installation/upgrade_120.html b/user_guide/installation/upgrade_120.html
index 0c251cb8c..ee4b1b214 100644
--- a/user_guide/installation/upgrade_120.html
+++ b/user_guide/installation/upgrade_120.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/installation/upgrade_130.html b/user_guide/installation/upgrade_130.html
index 7a296defe..9a5f7d723 100644
--- a/user_guide/installation/upgrade_130.html
+++ b/user_guide/installation/upgrade_130.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/installation/upgrade_131.html b/user_guide/installation/upgrade_131.html
index f74eadc01..0edef1d5d 100644
--- a/user_guide/installation/upgrade_131.html
+++ b/user_guide/installation/upgrade_131.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/installation/upgrade_132.html b/user_guide/installation/upgrade_132.html
index 628ce9b34..e3cd1abfb 100644
--- a/user_guide/installation/upgrade_132.html
+++ b/user_guide/installation/upgrade_132.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/installation/upgrade_133.html b/user_guide/installation/upgrade_133.html
index 3aa8a633a..ece73a58c 100644
--- a/user_guide/installation/upgrade_133.html
+++ b/user_guide/installation/upgrade_133.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/installation/upgrade_140.html b/user_guide/installation/upgrade_140.html
index bc5fab1fb..04e68f356 100644
--- a/user_guide/installation/upgrade_140.html
+++ b/user_guide/installation/upgrade_140.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/installation/upgrade_141.html b/user_guide/installation/upgrade_141.html
index 698678885..ff4bcc39b 100644
--- a/user_guide/installation/upgrade_141.html
+++ b/user_guide/installation/upgrade_141.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/installation/upgrade_150.html b/user_guide/installation/upgrade_150.html
index 6b15a8e84..9a3e801e0 100644
--- a/user_guide/installation/upgrade_150.html
+++ b/user_guide/installation/upgrade_150.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/installation/upgrade_152.html b/user_guide/installation/upgrade_152.html
index 7a3e89557..22d8d2883 100644
--- a/user_guide/installation/upgrade_152.html
+++ b/user_guide/installation/upgrade_152.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/installation/upgrade_153.html b/user_guide/installation/upgrade_153.html
index 7c4554224..54dabda3d 100644
--- a/user_guide/installation/upgrade_153.html
+++ b/user_guide/installation/upgrade_153.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/installation/upgrade_154.html b/user_guide/installation/upgrade_154.html
index 8b94fdf7a..c1c90b338 100644
--- a/user_guide/installation/upgrade_154.html
+++ b/user_guide/installation/upgrade_154.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/installation/upgrade_160.html b/user_guide/installation/upgrade_160.html
new file mode 100644
index 000000000..9aa15b2e9
--- /dev/null
+++ b/user_guide/installation/upgrade_160.html
@@ -0,0 +1,108 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html>
+<head>
+
+<title>CodeIgniter User Guide : Upgrading from 1.5.3 to 1.5.4</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='Rick Ellis' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle.jpg" width="153" height="44" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://www.codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Upgrading from 1.5.3 to 1.5.4
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+<h1>Upgrading from 1.5.4 to 1.6.0</h1>
+
+<p>Before performing an update you should take your site offline by replacing the index.php file with a static one.</p>
+
+
+
+<h2>Step 1: Update your CodeIgniter files</h2>
+
+<p>Replace these files and directories in your "system" folder with the new versions:</p>
+
+<ul>
+
+<li><dfn>system/codeigniter</dfn></li>
+<li><dfn>system/database</dfn></li>
+<li><dfn>system/helpers</dfn></li>
+<li><dfn>system/libraries</dfn></li>
+<li><dfn>system/plugins</dfn></li>
+<li><dfn>system/language</dfn></li>
+</ul>
+
+<p class="important"><strong>Note:</strong> If you have any custom developed files in these folders please make copies of them first.</p>
+
+<h2>Step 2: Add time_to_update to your config.php </h2>
+<p>Add the following to system/application/config/config.php with the other session configuration options</p>
+<p><code>$config['sess_time_to_update'] = 300;</code></p>
+
+<h2>Step 3: Add to your database.php </h2>
+<p>Add the following to system/application/config/database.php with the other database configuration options</p>
+<p><code>$db['default']['char_set'] = &quot;utf8&quot;;<br />
+$db['default']['dbcollat'] = &quot;utf8_general_ci&quot;;</code></p>
+
+<h2>Step 4: Update your user guide</h2>
+<p>Please also replace your local copy of the user guide with the new version.</p>
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="index.html">Installation Instructions</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="../overview/at_a_glance.html">CodeIgniter at a Glance</a>
+</p>
+<p><a href="http://www.codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2007 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">Ellislab, Inc.</a></p>
+</div>
+
+</body>
+</html> \ No newline at end of file
diff --git a/user_guide/installation/upgrade_b11.html b/user_guide/installation/upgrade_b11.html
index 7253e4fc5..a57d55299 100644
--- a/user_guide/installation/upgrade_b11.html
+++ b/user_guide/installation/upgrade_b11.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/installation/upgrading.html b/user_guide/installation/upgrading.html
index 6546a5bb6..ecc00b2f3 100644
--- a/user_guide/installation/upgrading.html
+++ b/user_guide/installation/upgrading.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/libraries/benchmark.html b/user_guide/libraries/benchmark.html
index f17554e0c..af83f8e57 100644
--- a/user_guide/libraries/benchmark.html
+++ b/user_guide/libraries/benchmark.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/libraries/calendar.html b/user_guide/libraries/calendar.html
index ae6c571ae..698df01cf 100644
--- a/user_guide/libraries/calendar.html
+++ b/user_guide/libraries/calendar.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/libraries/config.html b/user_guide/libraries/config.html
index 3eec0a028..67352adca 100644
--- a/user_guide/libraries/config.html
+++ b/user_guide/libraries/config.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/libraries/email.html b/user_guide/libraries/email.html
index 527c34a4e..c59374ca9 100644
--- a/user_guide/libraries/email.html
+++ b/user_guide/libraries/email.html
@@ -1 +1,299 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>CodeIgniter User Guide : Email Class</title> <style type='text/css' media='all'>@import url('../userguide.css');</style> <link rel='stylesheet' type='text/css' media='all' href='../userguide.css' /> <script type="text/javascript" src="../nav/nav.js"></script> <script type="text/javascript" src="../nav/prototype.lite.js"></script> <script type="text/javascript" src="../nav/moo.fx.js"></script> <script type="text/javascript" src="../nav/user_guide_menu.js"></script> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv='expires' content='-1' /> <meta http-equiv= 'pragma' content='no-cache' /> <meta name='robots' content='all' /> <meta name='author' content='Rick Ellis' /> <meta name='description' content='CodeIgniter User Guide' /> </head> <body> <!-- START NAVIGATION --> <div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div> <div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle.jpg" width="153" height="44" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div> <div id="masthead"> <table cellpadding="0" cellspacing="0" border="0" style="width:100%"> <tr> <td><h1>CodeIgniter User Guide Version 1.5.4</h1></td> <td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td> </tr> </table> </div> <!-- END NAVIGATION --> <!-- START BREADCRUMB --> <table cellpadding="0" cellspacing="0" border="0" style="width:100%"> <tr> <td id="breadcrumb"> <a href="http://www.codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp; <a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp; Email Class </td> <td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td> </tr> </table> <!-- END BREADCRUMB --> <br clear="all" /> <!-- START CONTENT --> <div id="content"> <h1>Email Class</h1> <p>CodeIgniter's robust Email Class supports the following features:</p> <ul> <li>Multiple Protocols: Mail, Sendmail, and SMTP</li> <li>Multiple recipients</li> <li>CC and BCCs</li> <li>HTML or Plaintext email</li> <li>Attachments</li> <li>Word wrapping</li> <li>Priorities</li> <li>BCC Batch Mode, enabling large email lists to be broken into small BCC batches.</li> <li>Email Debugging tools</li> </ul> <h2>Sending Email</h2> <p>Sending email is not only simple, but you can configure it on the fly or set your preferences in a config file.</p> <p>Here is a basic example demonstrating how you might send email. Note: This example assumes you are sending the email from one of your <a href="../general/controllers.html">controllers</a>.</p> <code>$this->load->library('email');<br /> <br /> $this->email->from('your@your-site.com', 'Your Name');<br /> $this->email->to('someone@example.com'); <br /> $this->email->cc('another@another-example.com'); <br /> $this->email->bcc('them@their-example.com'); <br /> <br /> $this->email->subject('Email Test');<br /> $this->email->message('Testing the email class.'); <br /> <br /> $this->email->send();<br /> <br /> echo $this->email->print_debugger();</code> <h2>Setting Email Preferences</h2> <p>There are 17 different preferences available to tailor how your email messages are sent. You can either set them manually as described here, or automatically via preferences stored in your config file, described below:</p> <p>Preferences are set by passing an array of preference values to the email <dfn>initialize</dfn> function. Here is an example of how you might set some preferences:</p> <code>$config['protocol'] = 'sendmail';<br /> $config['mailpath'] = '/usr/sbin/sendmail';<br /> $config['charset'] = 'iso-8859-1';<br /> $config['wordwrap'] = TRUE;<br /> <br /> $this->email->initialize($config);</code> <p><strong>Note:</strong> Most of the preferences have default values that will be used if you do not set them.</p ><h3>Setting Email Preferences in a Config File</h3> <p>If you prefer not to set preferences using the above method, you can instead put them into a config file. Simply create a new file called the <var>email.php</var>, add the <var>$config</var> array in that file. Then save the file at <var>config/email.php</var> and it will be used automatically. You will NOT need to use the <dfn>$this->email->initialize()</dfn> function if you save your preferences in a config file.</p> <h2>Email Preferences</h2> <p>The following is a list of all the preferences that can be set when sending email.</p> <table cellpadding="0" cellspacing="1" border="0" style="width:100%" class="tableborder"> <tr> <th>Preference</th> <th>Default&nbsp;Value</th> <th>Options</th> <th>Description</th> </tr><tr> <td class="td"><strong>useragent</strong></td><td class="td">CodeIgniter</td><td class="td">None</td><td class="td">The "user agent".</td> </tr><tr> <td class="td"><strong>protocol</strong></td><td class="td">mail</td><td class="td">mail, sendmail, or smtp</td><td class="td">The mail sending protocol.</td> </tr><tr> <td class="td"><strong>mailpath</strong></td><td class="td">/usr/sbin/sendmail</td><td class="td">None</td><td class="td">The server path to Sendmail.</td> </tr><tr> <td class="td"><strong>smtp_host</strong></td><td class="td">No Default</td><td class="td">None</td><td class="td">SMTP Server Address.</td> </tr><tr> <td class="td"><strong>smtp_user</strong></td><td class="td">No Default</td><td class="td">None</td><td class="td">SMTP Username.</td> </tr><tr> <td class="td"><strong>smtp_pass</strong></td><td class="td">No Default</td><td class="td">None</td><td class="td">SMTP Password.</td> </tr><tr> <td class="td"><strong>smtp_port</strong></td><td class="td">25</td><td class="td">None</td><td class="td">SMTP Port.</td> </tr><tr> <td class="td"><strong>smtp_timeout</strong></td><td class="td">5</td><td class="td">None</td><td class="td">SMTP Timeout (in seconds).</td> </tr><tr> <td class="td"><strong>wordwrap</strong></td><td class="td">TRUE</td><td class="td">TRUE or FALSE (boolean)</td><td class="td">Enable word-wrap.</td> </tr><tr> <td class="td"><strong>wrapchars</strong></td><td class="td">76</td><td class="td"> </td><td class="td">Character count to wrap at.</td> </tr><tr> <td class="td"><strong>mailtype</strong></td><td class="td">text</td><td class="td">text or html</td><td class="td">Type of mail. If you send HTML email you must send it as a complete web page. Make sure you don't have any relative links or relative image paths otherwise they will not work.</td> </tr><tr> <td class="td"><strong>charset</strong></td><td class="td">utf-8</td><td class="td"></td><td class="td">Character set (utf-8, iso-8859-1, etc.).</td> </tr><tr> <td class="td"><strong>validate</strong></td><td class="td">FALSE</td><td class="td">TRUE or FALSE (boolean)</td><td class="td">Whether to validate the email address.</td> </tr><tr> <td class="td"><strong>priority</strong></td><td class="td">3</td><td class="td">1, 2, 3, 4, 5</td><td class="td">Email Priority. 1 = highest. 5 = lowest. 3 = normal.</td> </tr><tr> <td class="td"><strong>newline</strong></td><td class="td">\n</td><td class="td">"\r\n" or "\n"</td><td class="td">Newline character. (Use "\r\n" to comply with RFC 822).</td> </tr><tr> <td class="td"><strong>bcc_batch_mode</strong></td><td class="td">FALSE</td><td class="td">TRUE or FALSE (boolean)</td><td class="td">Enable BCC Batch Mode.</td> </tr><tr> <td class="td"><strong>bcc_batch_size</strong></td><td class="td">200</td><td class="td">None</td><td class="td">Number of emails in each BCC batch.</td> </tr> </table> <h2>Email Function Reference</h2> <h3>$this->email->from()</h3> <p>Sets the email address and name of the person sending the email:</p> <code>$this->email->from('<var>you@your-site.com</var>', '<var>Your Name</var>');</code> <h3>$this->email->reply_to()</h3> <p>Sets the reply-to address. If the information is not provided the information in the "from" function is used. Example:</p> <code>$this->email->reply_to('<var>you@your-site.com</var>', '<var>Your Name</var>');</code> <h3>$this->email->to()</h3> <p>Sets the email address(s) of the recipient(s). Can be a single email, a comma-delimited list or an array:</p> <code>$this->email->to('<var>someone@example.com</var>');</code> <code>$this->email->to('<var>one@example.com</var>, <var>two@example.com</var>, <var>three@example.com</var>');</code> <code>$list = array('<var>one@example.com</var>', '<var>two@example.com</var>', '<var>three@example.com</var>');<br /> <br /> $this->email->to(<var>$list</var>);</code> <h3>$this->email->cc()</h3> <p>Sets the CC email address(s). Just like the "to", can be a single email, a comma-delimited list or an array.</p> <h3>$this->email->bcc()</h3> <p>Sets the BCC email address(s). Just like the "to", can be a single email, a comma-delimited list or an array.</p> <h3>$this->email->subject()</h3> <p>Sets the email subject:</p> <code>$this->email->subject('<var>This is my subject</var>');</code> <h3>$this->email->message()</h3> <p>Sets the email message body:</p> <code>$this->email->message('<var>This is my message</var>');</code> <h3>$this->email->set_alt_message()</h3> <p>Sets the alternative email message body:</p> <code>$this->email->set_alt_message('<var>This is the alternative message</var>');</code> <p>This is an optional message string which can be used if you send HTML formatted email. It lets you specify an alternative message with no HTML formatting which is added to the header string for people who do not accept HTML email. If you do not set your own message CodeIgniter will extract the message from your HTML email and strip the tags.</p> <h3>$this->email->clear()</h3> <p>Initializes all the email variables to an empty state. This function is intended for use if you run the email sending function in a loop, permitting the data to be reset between cycles.</p> <code>foreach ($list as $name => $address)<br /> {<br /> &nbsp;&nbsp;&nbsp;&nbsp;$this->email->clear();<br /><br /> &nbsp;&nbsp;&nbsp;&nbsp;$this->email->to($address);<br /> &nbsp;&nbsp;&nbsp;&nbsp;$this->email->from('your@your-site.com');<br /> &nbsp;&nbsp;&nbsp;&nbsp;$this->email->subject('Here is your info '.$name);<br /> &nbsp;&nbsp;&nbsp;&nbsp;$this->email->message('Hi '.$name.' Here is the info you requested.');<br /> &nbsp;&nbsp;&nbsp;&nbsp;$this->email->send();<br /> }</code> <p>If you set the parameter to TRUE any attachments will be cleared as well:</p> <code>$this->email->clear(TRUE);</code> <h3>$this->email->send()</h3> <p>The Email sending function. Returns boolean TRUE or FALSE based on success or failure, enabling it to be used conditionally:</p> <code>if ( ! $this->email->send())<br /> {<br /> &nbsp;&nbsp;&nbsp;&nbsp;// Generate error<br /> }</code> <h3>$this->email->attach()</h3> <p>Enables you to send an attachment. Put the file path/name in the first parameter. Note: Use a file path, not a URL. For multiple attachments use the function multiple times. For example:</p> <code>$this->email->attach('/path/to/photo1.jpg');<br /> $this->email->attach('/path/to/photo2.jpg');<br /> $this->email->attach('/path/to/photo3.jpg');<br /> <br /> $this->email->send();</code> <h3>$this->email->print_debugger()</h3> <p>Returns a string containing any server messages, the email headers, and the email messsage. Useful for debugging.</p> <h2>Overriding Word Wrapping</h2> <p>If you have word wrapping enabled (recommended to comply with RFC 822) and you have a very long link in your email it can get wrapped too, causing it to become un-clickable by the person receiving it. CodeIgniter lets you manually override word wrapping within part of your message like this:</p> <code>The text of your email that<br /> gets wrapped normally.<br /> <br /> <var>{unwrap}</var>http://www.example.com/a_long_link_that_should_not_be_wrapped.html<var>{/unwrap}</var><br /> <br /> More text that will be<br /> wrapped normally.</code> <p>Place the item you do not want word-wrapped between: <var>{unwrap}</var> <var>{/unwrap}</var></p> </div> <!-- END CONTENT --> <div id="footer"> <p> Previous Topic:&nbsp;&nbsp;<a href="database/index.html">Database Class</a> &nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp; <a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp; <a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp; Next Topic:&nbsp;&nbsp;<a href="encryption.html">Encryption Class</a> </p> <p><a href="http://www.codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2007 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">Ellislab, Inc.</a></p> </div> </body> </html> \ No newline at end of file
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html>
+<head>
+
+<title>CodeIgniter User Guide : Email Class</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='Rick Ellis' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle.jpg" width="153" height="44" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://www.codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Email Class
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+
+<h1>Email Class</h1>
+
+<p>CodeIgniter's robust Email Class supports the following features:</p>
+
+
+<ul>
+<li>Multiple Protocols: Mail, Sendmail, and SMTP</li>
+<li>Multiple recipients</li>
+<li>CC and BCCs</li>
+<li>HTML or Plaintext email</li>
+<li>Attachments</li>
+<li>Word wrapping</li>
+<li>Priorities</li>
+<li>BCC Batch Mode, enabling large email lists to be broken into small BCC batches.</li>
+<li>Email Debugging tools</li>
+</ul>
+
+
+<h2>Sending Email</h2>
+
+<p>Sending email is not only simple, but you can configure it on the fly or set your preferences in a config file.</p>
+
+<p>Here is a basic example demonstrating how you might send email. Note: This example assumes you are sending the email from one of your
+<a href="../general/controllers.html">controllers</a>.</p>
+
+<code>$this->load->library('email');<br />
+<br />
+$this->email->from('your@your-site.com', 'Your Name');<br />
+$this->email->to('someone@example.com'); <br />
+$this->email->cc('another@another-example.com'); <br />
+$this->email->bcc('them@their-example.com'); <br />
+<br />
+$this->email->subject('Email Test');<br />
+$this->email->message('Testing the email class.'); <br />
+<br />
+$this->email->send();<br />
+<br />
+echo $this->email->print_debugger();</code>
+
+
+
+
+<h2>Setting Email Preferences</h2>
+
+<p>There are 17 different preferences available to tailor how your email messages are sent. You can either set them manually
+as described here, or automatically via preferences stored in your config file, described below:</p>
+
+<p>Preferences are set by passing an array of preference values to the email <dfn>initialize</dfn> function. Here is an example of how you might set some preferences:</p>
+
+<code>$config['protocol'] = 'sendmail';<br />
+$config['mailpath'] = '/usr/sbin/sendmail';<br />
+$config['charset'] = 'iso-8859-1';<br />
+$config['wordwrap'] = TRUE;<br />
+<br />
+$this->email->initialize($config);</code>
+
+<p><strong>Note:</strong> Most of the preferences have default values that will be used if you do not set them.</p
+
+><h3>Setting Email Preferences in a Config File</h3>
+
+<p>If you prefer not to set preferences using the above method, you can instead put them into a config file.
+Simply create a new file called the <var>email.php</var>, add the <var>$config</var>
+array in that file. Then save the file at <var>config/email.php</var> and it will be used automatically. You
+will NOT need to use the <dfn>$this->email->initialize()</dfn> function if you save your preferences in a config file.</p>
+
+
+
+
+<h2>Email Preferences</h2>
+
+<p>The following is a list of all the preferences that can be set when sending email.</p>
+
+
+<table cellpadding="0" cellspacing="1" border="0" style="width:100%" class="tableborder">
+<tr>
+<th>Preference</th>
+<th>Default&nbsp;Value</th>
+<th>Options</th>
+<th>Description</th>
+</tr><tr>
+<td class="td"><strong>useragent</strong></td><td class="td">CodeIgniter</td><td class="td">None</td><td class="td">The "user agent".</td>
+</tr><tr>
+<td class="td"><strong>protocol</strong></td><td class="td">mail</td><td class="td">mail, sendmail, or smtp</td><td class="td">The mail sending protocol.</td>
+</tr><tr>
+<td class="td"><strong>mailpath</strong></td><td class="td">/usr/sbin/sendmail</td><td class="td">None</td><td class="td">The server path to Sendmail.</td>
+</tr><tr>
+<td class="td"><strong>smtp_host</strong></td><td class="td">No Default</td><td class="td">None</td><td class="td">SMTP Server Address.</td>
+</tr><tr>
+<td class="td"><strong>smtp_user</strong></td><td class="td">No Default</td><td class="td">None</td><td class="td">SMTP Username.</td>
+</tr><tr>
+<td class="td"><strong>smtp_pass</strong></td><td class="td">No Default</td><td class="td">None</td><td class="td">SMTP Password.</td>
+</tr><tr>
+<td class="td"><strong>smtp_port</strong></td><td class="td">25</td><td class="td">None</td><td class="td">SMTP Port.</td>
+</tr><tr>
+<td class="td"><strong>smtp_timeout</strong></td><td class="td">5</td><td class="td">None</td><td class="td">SMTP Timeout (in seconds).</td>
+</tr><tr>
+<td class="td"><strong>wordwrap</strong></td><td class="td">TRUE</td><td class="td">TRUE or FALSE (boolean)</td><td class="td">Enable word-wrap.</td>
+</tr><tr>
+<td class="td"><strong>wrapchars</strong></td><td class="td">76</td><td class="td"> </td><td class="td">Character count to wrap at.</td>
+</tr><tr>
+<td class="td"><strong>mailtype</strong></td><td class="td">text</td><td class="td">text or html</td><td class="td">Type of mail. If you send HTML email you must send it as a complete web page. Make sure you don't have any relative links or relative image paths otherwise they will not work.</td>
+</tr><tr>
+<td class="td"><strong>charset</strong></td><td class="td">utf-8</td><td class="td"></td><td class="td">Character set (utf-8, iso-8859-1, etc.).</td>
+</tr><tr>
+<td class="td"><strong>validate</strong></td><td class="td">FALSE</td><td class="td">TRUE or FALSE (boolean)</td><td class="td">Whether to validate the email address.</td>
+</tr><tr>
+<td class="td"><strong>priority</strong></td><td class="td">3</td><td class="td">1, 2, 3, 4, 5</td><td class="td">Email Priority. 1 = highest. 5 = lowest. 3 = normal.</td>
+</tr><tr>
+<td class="td"><strong>newline</strong></td><td class="td">\n</td><td class="td">"\r\n" or "\n"</td><td class="td">Newline character. (Use "\r\n" to comply with RFC 822).</td>
+</tr><tr>
+<td class="td"><strong>bcc_batch_mode</strong></td><td class="td">FALSE</td><td class="td">TRUE or FALSE (boolean)</td><td class="td">Enable BCC Batch Mode.</td>
+</tr><tr>
+<td class="td"><strong>bcc_batch_size</strong></td><td class="td">200</td><td class="td">None</td><td class="td">Number of emails in each BCC batch.</td>
+</tr>
+</table>
+
+
+<h2>Email Function Reference</h2>
+
+<h3>$this->email->from()</h3>
+<p>Sets the email address and name of the person sending the email:</p>
+<code>$this->email->from('<var>you@your-site.com</var>', '<var>Your Name</var>');</code>
+
+<h3>$this->email->reply_to()</h3>
+<p>Sets the reply-to address. If the information is not provided the information in the "from" function is used. Example:</p>
+<code>$this->email->reply_to('<var>you@your-site.com</var>', '<var>Your Name</var>');</code>
+
+
+<h3>$this->email->to()</h3>
+<p>Sets the email address(s) of the recipient(s). Can be a single email, a comma-delimited list or an array:</p>
+
+<code>$this->email->to('<var>someone@example.com</var>');</code>
+<code>$this->email->to('<var>one@example.com</var>, <var>two@example.com</var>, <var>three@example.com</var>');</code>
+
+<code>$list = array('<var>one@example.com</var>', '<var>two@example.com</var>', '<var>three@example.com</var>');<br />
+<br />
+$this->email->to(<var>$list</var>);</code>
+
+<h3>$this->email->cc()</h3>
+<p>Sets the CC email address(s). Just like the "to", can be a single email, a comma-delimited list or an array.</p>
+
+<h3>$this->email->bcc()</h3>
+<p>Sets the BCC email address(s). Just like the "to", can be a single email, a comma-delimited list or an array.</p>
+
+
+<h3>$this->email->subject()</h3>
+<p>Sets the email subject:</p>
+<code>$this->email->subject('<var>This is my subject</var>');</code>
+
+<h3>$this->email->message()</h3>
+<p>Sets the email message body:</p>
+<code>$this->email->message('<var>This is my message</var>');</code>
+
+<h3>$this->email->set_alt_message()</h3>
+<p>Sets the alternative email message body:</p>
+<code>$this->email->set_alt_message('<var>This is the alternative message</var>');</code>
+
+<p>This is an optional message string which can be used if you send HTML formatted email. It lets you specify an alternative
+message with no HTML formatting which is added to the header string for people who do not accept HTML email.
+If you do not set your own message CodeIgniter will extract the message from your HTML email and strip the tags.</p>
+
+
+
+<h3>$this->email->clear()</h3>
+<p>Initializes all the email variables to an empty state. This function is intended for use if you run the email sending function
+in a loop, permitting the data to be reset between cycles.</p>
+<code>foreach ($list as $name => $address)<br />
+{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;$this->email->clear();<br /><br />
+
+&nbsp;&nbsp;&nbsp;&nbsp;$this->email->to($address);<br />
+&nbsp;&nbsp;&nbsp;&nbsp;$this->email->from('your@your-site.com');<br />
+&nbsp;&nbsp;&nbsp;&nbsp;$this->email->subject('Here is your info '.$name);<br />
+&nbsp;&nbsp;&nbsp;&nbsp;$this->email->message('Hi '.$name.' Here is the info you requested.');<br />
+&nbsp;&nbsp;&nbsp;&nbsp;$this->email->send();<br />
+}</code>
+
+<p>If you set the parameter to TRUE any attachments will be cleared as well:</p>
+
+<code>$this->email->clear(TRUE);</code>
+
+
+<h3>$this->email->send()</h3>
+<p>The Email sending function. Returns boolean TRUE or FALSE based on success or failure, enabling it to be used
+conditionally:</p>
+
+<code>if ( ! $this->email->send())<br />
+{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;// Generate error<br />
+}</code>
+
+
+<h3>$this->email->attach()</h3>
+<p>Enables you to send an attachment. Put the file path/name in the first parameter. Note: Use a file path, not a URL.
+For multiple attachments use the function multiple times. For example:</p>
+
+<code>$this->email->attach('/path/to/photo1.jpg');<br />
+$this->email->attach('/path/to/photo2.jpg');<br />
+$this->email->attach('/path/to/photo3.jpg');<br />
+<br />
+$this->email->send();</code>
+
+
+<h3>$this->email->print_debugger()</h3>
+<p>Returns a string containing any server messages, the email headers, and the email messsage. Useful for debugging.</p>
+
+
+<h2>Overriding Word Wrapping</h2>
+
+<p>If you have word wrapping enabled (recommended to comply with RFC 822) and you have a very long link in your email it can
+get wrapped too, causing it to become un-clickable by the person receiving it. CodeIgniter lets you manually override
+word wrapping within part of your message like this:</p>
+
+<code>The text of your email that<br />
+gets wrapped normally.<br />
+<br />
+<var>{unwrap}</var>http://www.example.com/a_long_link_that_should_not_be_wrapped.html<var>{/unwrap}</var><br />
+<br />
+More text that will be<br />
+wrapped normally.</code>
+
+<p>Place the item you do not want word-wrapped between: <var>{unwrap}</var> <var>{/unwrap}</var></p>
+
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="database/index.html">Database Class</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="encryption.html">Encryption Class</a>
+</p>
+<p><a href="http://www.codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2007 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">Ellislab, Inc.</a></p>
+</div>
+
+</body>
+</html> \ No newline at end of file
diff --git a/user_guide/libraries/encryption.html b/user_guide/libraries/encryption.html
index ab6195cb1..f3b3d4406 100644
--- a/user_guide/libraries/encryption.html
+++ b/user_guide/libraries/encryption.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/libraries/file_uploading.html b/user_guide/libraries/file_uploading.html
index 86ee0cc85..46865acad 100644
--- a/user_guide/libraries/file_uploading.html
+++ b/user_guide/libraries/file_uploading.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/libraries/ftp.html b/user_guide/libraries/ftp.html
index b88b640ac..585811966 100644
--- a/user_guide/libraries/ftp.html
+++ b/user_guide/libraries/ftp.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/libraries/image_lib.html b/user_guide/libraries/image_lib.html
index 83dc8b3c0..39c1bd27f 100644
--- a/user_guide/libraries/image_lib.html
+++ b/user_guide/libraries/image_lib.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/libraries/input.html b/user_guide/libraries/input.html
index de623c07b..2bca88aed 100644
--- a/user_guide/libraries/input.html
+++ b/user_guide/libraries/input.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/libraries/language.html b/user_guide/libraries/language.html
index 7883e2a04..3ee62008d 100644
--- a/user_guide/libraries/language.html
+++ b/user_guide/libraries/language.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/libraries/loader.html b/user_guide/libraries/loader.html
index 7ff597c64..6aec87c13 100644
--- a/user_guide/libraries/loader.html
+++ b/user_guide/libraries/loader.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/libraries/output.html b/user_guide/libraries/output.html
index 27a458a87..2d131956e 100644
--- a/user_guide/libraries/output.html
+++ b/user_guide/libraries/output.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/libraries/pagination.html b/user_guide/libraries/pagination.html
index d18d364f2..e05a6e887 100644
--- a/user_guide/libraries/pagination.html
+++ b/user_guide/libraries/pagination.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/libraries/parser.html b/user_guide/libraries/parser.html
index a5271dea9..dab6937e2 100644
--- a/user_guide/libraries/parser.html
+++ b/user_guide/libraries/parser.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/libraries/table.html b/user_guide/libraries/table.html
index 0e627d120..93eb38ddb 100644
--- a/user_guide/libraries/table.html
+++ b/user_guide/libraries/table.html
@@ -1 +1,292 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>CodeIgniter User Guide : HTML Table Class</title> <style type='text/css' media='all'>@import url('../userguide.css');</style> <link rel='stylesheet' type='text/css' media='all' href='../userguide.css' /> <script type="text/javascript" src="../nav/nav.js"></script> <script type="text/javascript" src="../nav/prototype.lite.js"></script> <script type="text/javascript" src="../nav/moo.fx.js"></script> <script type="text/javascript" src="../nav/user_guide_menu.js"></script> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv='expires' content='-1' /> <meta http-equiv= 'pragma' content='no-cache' /> <meta name='robots' content='all' /> <meta name='author' content='Rick Ellis' /> <meta name='description' content='CodeIgniter User Guide' /> </head> <body> <!-- START NAVIGATION --> <div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div> <div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle.jpg" width="153" height="44" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div> <div id="masthead"> <table cellpadding="0" cellspacing="0" border="0" style="width:100%"> <tr> <td><h1>CodeIgniter User Guide Version 1.5.4</h1></td> <td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td> </tr> </table> </div> <!-- END NAVIGATION --> <!-- START BREADCRUMB --> <table cellpadding="0" cellspacing="0" border="0" style="width:100%"> <tr> <td id="breadcrumb"> <a href="http://www.codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp; <a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp; HTML Table Class </td> <td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td> </tr> </table> <!-- END BREADCRUMB --> <br clear="all" /> <!-- START CONTENT --> <div id="content"> <h1>HTML Table Class</h1> <p>The Table Class provides functions that enable you to auto-generate HTML tables from arrays or database result sets.</p> <h2>Initializing the Class</h2> <p>Like most other classes in CodeIgniter, the Table class is initialized in your controller using the <dfn>$this->load->library</dfn> function:</p> <code>$this->load->library('table');</code> <p>Once loaded, the Table library object will be available using: <dfn>$this->table</dfn></p> <h2>Examples</h2> <p>Here is an example showing how you can create a table from a multi-dimensional array. Note that the first array index will become the table heading (or you can set your own headings using the <dfn>set_heading()</dfn> function described in the function reference below).</p> <code> $this->load->library('table');<br /> <br /> $data = array(<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array('Name', 'Color', 'Size'),<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array('Fred', 'Blue', 'Small'),<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array('Mary', 'Red', 'Large'),<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array('John', 'Green', 'Medium') <br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);<br /> <br /> echo $this->table->generate($data); </code> <p>Here is an example of a table created from a database query result. The table class will automatically generate the headings based on the table names (or you can set your own headings using the <dfn>set_heading()</dfn> function described in the function reference below).</p> <code> $this->load->library('table');<br /> <br /> $query = $this->db->query("SELECT * FROM my_table");<br /> <br /> echo $this->table->generate($query); </code> <p>Here is an example showing how you might create a table using discreet parameters:</p> <code> $this->load->library('table');<br /> <br /> $this->table->set_heading('Name', 'Color', 'Size');<br /> <br /> $this->table->add_row('Fred', 'Blue', 'Small');<br /> $this->table->add_row('Mary', 'Red', 'Large');<br /> $this->table->add_row('John', 'Green', 'Medium');<br /> <br /> echo $this->table->generate(); </code> <p>Here is the same example, except instead of individual parameters, arrays are used:</p> <code> $this->load->library('table');<br /> <br /> $this->table->set_heading(array('Name', 'Color', 'Size'));<br /> <br /> $this->table->add_row(array('Fred', 'Blue', 'Small'));<br /> $this->table->add_row(array('Mary', 'Red', 'Large'));<br /> $this->table->add_row(array('John', 'Green', 'Medium'));<br /> <br /> echo $this->table->generate(); </code> <h2>Changing the Look of Your Table</h2> <p>The Table Class permits you to set a table template with which you can specify the design of your layout. Here is the template prototype:</p> <code> $tmpl = array (<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'table_open'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=> '&lt;table border="0" cellpadding="4" cellspacing="0">',<br /> <br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'heading_row_start'&nbsp;&nbsp;&nbsp;=> '&lt;tr>',<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'heading_row_end'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=> '&lt;/tr>',<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'heading_cell_start'&nbsp;&nbsp;=> '&lt;th>',<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'heading_cell_end'&nbsp;&nbsp;&nbsp;&nbsp;=> '&lt;/th>',<br /> <br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'row_start'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=> '&lt;tr>',<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'row_end'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=> '&lt;/tr>',<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'cell_start'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=> '&lt;td>',<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'cell_end'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=> '&lt;/td>',<br /> <br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'row_alt_start'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=> '&lt;tr>',<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'row_alt_end'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=> '&lt;/tr>',<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'cell_alt_start'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=> '&lt;td>',<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'cell_alt_end'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=> '&lt;/td>',<br /> <br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'table_close'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=> '&lt;/table>'<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);<br /> <br /> $this->table->set_template($tmpl); </code> <p class="important"><strong>Note:</strong>&nbsp; You'll notice there are two sets of "row" blocks in the template. These permit you to create alternating row colors or design elements that alternate with each iteration of the row data.</p> <p>You are NOT required to submit a complete template. If you only need to change parts of the layout you can simply submit those elements. In this example, only the table opening tag is being changed:</p> <code> $tmpl = array ( 'table_open'&nbsp;&nbsp;=> '&lt;table border="1" cellpadding="2" cellspacing="1" class="mytable">' );<br /> <br /> $this->table->set_template($tmpl); </code> <br /> <h1>Function Reference</h1> <h2>$this->table->generate()</h2> <p>Returns a string containing the generated table. Accepts an optional parameter which can be an array or a database result object.</p> <h2>$this->table->set_caption()</h2> <p>Permits you to add a caption to the table.</p> <code>$this->table->set_caption('Colors');</code> <h2>$this->table->set_heading()</h2> <p>Permits you to set the table heading. You can submit an array or discreet params:</p> <code>$this->table->set_heading('Name', 'Color', 'Size');</code> <code>$this->table->set_heading(array('Name', 'Color', 'Size'));</code> <h2>$this->table->add_row()</h2> <p>Permits you to add a row to your table. You can submit an array or discreet params:</p> <code>$this->table->add_row('Blue', 'Red', 'Green');</code> <code>$this->table->add_row(array('Blue', 'Red', 'Green'));</code> <h2>$this->table->make_columns()</h2> <p>This function takes a one-dimensional array as input and creates a multi-dimensional array with a depth equal to the number of columns desired. This allows a single array with many elements to be displayed in a table that has a fixed column count. Consider this example:</p> <code> $list = array('one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve');<br /> <br /> $new_list = $this->table->make_columns($list, 3);<br /> <br /> $this->table->generate($new_list);<br /> <br /> // Generates a table with this prototype<br /> <br /> &lt;table border="0" cellpadding="4" cellspacing="0"&gt;<br /> &lt;tr&gt;<br /> &lt;td&gt;one&lt;/td&gt;&lt;td&gt;two&lt;/td&gt;&lt;td&gt;three&lt;/td&gt;<br /> &lt;/tr&gt;&lt;tr&gt;<br /> &lt;td&gt;four&lt;/td&gt;&lt;td&gt;five&lt;/td&gt;&lt;td&gt;six&lt;/td&gt;<br /> &lt;/tr&gt;&lt;tr&gt;<br /> &lt;td&gt;seven&lt;/td&gt;&lt;td&gt;eight&lt;/td&gt;&lt;td&gt;nine&lt;/td&gt;<br /> &lt;/tr&gt;&lt;tr&gt;<br /> &lt;td&gt;ten&lt;/td&gt;&lt;td&gt;eleven&lt;/td&gt;&lt;td&gt;twelve&lt;/td&gt;&lt;/tr&gt;<br /> &lt;/table&gt;</code> <h2>$this->table->set_template()</h2> <p>Permits you to set your template. You can submit a full or partial template.</p> <code> $tmpl = array ( 'table_open'&nbsp;&nbsp;=> '&lt;table border="1" cellpadding="2" cellspacing="1" class="mytable">' );<br /> <br /> $this->table->set_template($tmpl); </code> <h2>$this->table->set_empty()</h2> <p>Let's you set a default value for use in any table cells that are empty. You might, for example, set a non-breaking space:</p> <code> $this->table->set_empty("&amp;nbsp;"); </code> <h2>$this->table->clear()</h2> <p>Lets you clear the table heading and row data. If you need to show multiple tables with different data you should to call this function after each table has been generated to empty the previous table information. Example:</p> <code> $this->load->library('table');<br /> <br /> $this->table->set_heading('Name', 'Color', 'Size');<br /> $this->table->add_row('Fred', 'Blue', 'Small');<br /> $this->table->add_row('Mary', 'Red', 'Large');<br /> $this->table->add_row('John', 'Green', 'Medium');<br /> <br /> echo $this->table->generate();<br /> <br /> <kbd>$this->table->clear();</kbd><br /> <br /> $this->table->set_heading('Name', 'Day', 'Delivery');<br /> $this->table->add_row('Fred', 'Wednesday', 'Express');<br /> $this->table->add_row('Mary', 'Monday', 'Air');<br /> $this->table->add_row('John', 'Saturday', 'Overnight');<br /> <br /> echo $this->table->generate(); </code> </div> <!-- END CONTENT --> <div id="footer"> <p> Previous Topic:&nbsp;<a href="ftp.html">&nbsp;FTP Class</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp; <a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp; <a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp; Next Topic:&nbsp;&nbsp;<a href="image_lib.html">Image Manipulation Class</a> </p> <p><a href="http://www.codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2007 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">Ellislab, Inc.</a></p> </div> </body> </html> \ No newline at end of file
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html>
+<head>
+
+<title>CodeIgniter User Guide : HTML Table Class</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='Rick Ellis' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle.jpg" width="153" height="44" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://www.codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+HTML Table Class
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+
+<h1>HTML Table Class</h1>
+
+<p>The Table Class provides functions that enable you to auto-generate HTML tables from arrays or database result sets.</p>
+
+<h2>Initializing the Class</h2>
+
+<p>Like most other classes in CodeIgniter, the Table class is initialized in your controller using the <dfn>$this->load->library</dfn> function:</p>
+
+<code>$this->load->library('table');</code>
+<p>Once loaded, the Table library object will be available using: <dfn>$this->table</dfn></p>
+
+
+<h2>Examples</h2>
+
+<p>Here is an example showing how you can create a table from a multi-dimensional array.
+Note that the first array index will become the table heading (or you can set your own headings using the
+<dfn>set_heading()</dfn> function described in the function reference below).</p>
+
+<code>
+$this->load->library('table');<br />
+<br />
+$data = array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array('Name', 'Color', 'Size'),<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array('Fred', 'Blue', 'Small'),<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array('Mary', 'Red', 'Large'),<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array('John', 'Green', 'Medium') <br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);<br />
+<br />
+echo $this->table->generate($data);
+</code>
+
+<p>Here is an example of a table created from a database query result. The table class will automatically generate the
+headings based on the table names (or you can set your own headings using the <dfn>set_heading()</dfn> function described
+in the function reference below).</p>
+
+<code>
+$this->load->library('table');<br />
+<br />
+$query = $this->db->query("SELECT * FROM my_table");<br />
+<br />
+echo $this->table->generate($query);
+</code>
+
+
+<p>Here is an example showing how you might create a table using discreet parameters:</p>
+
+<code>
+$this->load->library('table');<br />
+<br />
+$this->table->set_heading('Name', 'Color', 'Size');<br />
+<br />
+$this->table->add_row('Fred', 'Blue', 'Small');<br />
+$this->table->add_row('Mary', 'Red', 'Large');<br />
+$this->table->add_row('John', 'Green', 'Medium');<br />
+<br />
+echo $this->table->generate();
+</code>
+
+<p>Here is the same example, except instead of individual parameters, arrays are used:</p>
+
+<code>
+$this->load->library('table');<br />
+<br />
+$this->table->set_heading(array('Name', 'Color', 'Size'));<br />
+<br />
+$this->table->add_row(array('Fred', 'Blue', 'Small'));<br />
+$this->table->add_row(array('Mary', 'Red', 'Large'));<br />
+$this->table->add_row(array('John', 'Green', 'Medium'));<br />
+<br />
+echo $this->table->generate();
+</code>
+
+
+<h2>Changing the Look of Your Table</h2>
+
+<p>The Table Class permits you to set a table template with which you can specify the design of your layout. Here is the template
+prototype:</p>
+
+<code>
+$tmpl = array (<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'table_open'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=> '&lt;table border="0" cellpadding="4" cellspacing="0">',<br />
+<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'heading_row_start'&nbsp;&nbsp;&nbsp;=> '&lt;tr>',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'heading_row_end'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=> '&lt;/tr>',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'heading_cell_start'&nbsp;&nbsp;=> '&lt;th>',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'heading_cell_end'&nbsp;&nbsp;&nbsp;&nbsp;=> '&lt;/th>',<br />
+<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'row_start'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=> '&lt;tr>',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'row_end'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=> '&lt;/tr>',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'cell_start'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=> '&lt;td>',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'cell_end'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=> '&lt;/td>',<br />
+<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'row_alt_start'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=> '&lt;tr>',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'row_alt_end'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=> '&lt;/tr>',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'cell_alt_start'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=> '&lt;td>',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'cell_alt_end'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=> '&lt;/td>',<br />
+<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'table_close'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=> '&lt;/table>'<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);<br />
+
+<br />
+$this->table->set_template($tmpl);
+</code>
+
+<p class="important"><strong>Note:</strong>&nbsp; You'll notice there are two sets of "row" blocks in the template. These permit you to create alternating row colors or design elements that alternate with each
+iteration of the row data.</p>
+
+<p>You are NOT required to submit a complete template. If you only need to change parts of the layout you can simply submit those elements.
+In this example, only the table opening tag is being changed:</p>
+
+<code>
+$tmpl = array ( 'table_open'&nbsp;&nbsp;=> '&lt;table border="1" cellpadding="2" cellspacing="1" class="mytable">' );<br />
+
+<br />
+$this->table->set_template($tmpl);
+</code>
+
+<br />
+<h1>Function Reference</h1>
+
+<h2>$this->table->generate()</h2>
+<p>Returns a string containing the generated table. Accepts an optional parameter which can be an array or a database result object.</p>
+
+<h2>$this->table->set_caption()</h2>
+
+<p>Permits you to add a caption to the table.</p>
+
+<code>$this->table->set_caption('Colors');</code>
+
+<h2>$this->table->set_heading()</h2>
+
+<p>Permits you to set the table heading. You can submit an array or discreet params:</p>
+
+<code>$this->table->set_heading('Name', 'Color', 'Size');</code>
+<code>$this->table->set_heading(array('Name', 'Color', 'Size'));</code>
+
+<h2>$this->table->add_row()</h2>
+
+<p>Permits you to add a row to your table. You can submit an array or discreet params:</p>
+
+<code>$this->table->add_row('Blue', 'Red', 'Green');</code>
+<code>$this->table->add_row(array('Blue', 'Red', 'Green'));</code>
+
+
+<h2>$this->table->make_columns()</h2>
+
+<p>This function takes a one-dimensional array as input and creates
+a multi-dimensional array with a depth equal to the number of
+columns desired. This allows a single array with many elements to be
+displayed in a table that has a fixed column count. Consider this example:</p>
+
+<code>
+$list = array('one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve');<br />
+<br />
+$new_list = $this->table->make_columns($list, 3);<br />
+<br />
+$this->table->generate($new_list);<br />
+<br />
+// Generates a table with this prototype<br />
+<br />
+&lt;table border="0" cellpadding="4" cellspacing="0"&gt;<br />
+&lt;tr&gt;<br />
+&lt;td&gt;one&lt;/td&gt;&lt;td&gt;two&lt;/td&gt;&lt;td&gt;three&lt;/td&gt;<br />
+&lt;/tr&gt;&lt;tr&gt;<br />
+&lt;td&gt;four&lt;/td&gt;&lt;td&gt;five&lt;/td&gt;&lt;td&gt;six&lt;/td&gt;<br />
+&lt;/tr&gt;&lt;tr&gt;<br />
+&lt;td&gt;seven&lt;/td&gt;&lt;td&gt;eight&lt;/td&gt;&lt;td&gt;nine&lt;/td&gt;<br />
+&lt;/tr&gt;&lt;tr&gt;<br />
+&lt;td&gt;ten&lt;/td&gt;&lt;td&gt;eleven&lt;/td&gt;&lt;td&gt;twelve&lt;/td&gt;&lt;/tr&gt;<br />
+&lt;/table&gt;</code>
+
+
+
+<h2>$this->table->set_template()</h2>
+
+<p>Permits you to set your template. You can submit a full or partial template.</p>
+
+<code>
+$tmpl = array ( 'table_open'&nbsp;&nbsp;=> '&lt;table border="1" cellpadding="2" cellspacing="1" class="mytable">' );<br />
+
+<br />
+$this->table->set_template($tmpl);
+</code>
+
+
+<h2>$this->table->set_empty()</h2>
+
+<p>Let's you set a default value for use in any table cells that are empty. You might, for example, set a non-breaking space:</p>
+
+<code>
+$this->table->set_empty("&amp;nbsp;");
+</code>
+
+<h2>$this->table->clear()</h2>
+
+<p>Lets you clear the table heading and row data. If you need to show multiple tables with different data you should
+to call this function after each table has been generated to empty the previous table information. Example:</p>
+
+<code>
+$this->load->library('table');<br />
+<br />
+$this->table->set_heading('Name', 'Color', 'Size');<br />
+$this->table->add_row('Fred', 'Blue', 'Small');<br />
+$this->table->add_row('Mary', 'Red', 'Large');<br />
+$this->table->add_row('John', 'Green', 'Medium');<br />
+<br />
+echo $this->table->generate();<br />
+<br />
+<kbd>$this->table->clear();</kbd><br />
+<br />
+$this->table->set_heading('Name', 'Day', 'Delivery');<br />
+$this->table->add_row('Fred', 'Wednesday', 'Express');<br />
+$this->table->add_row('Mary', 'Monday', 'Air');<br />
+$this->table->add_row('John', 'Saturday', 'Overnight');<br />
+<br />
+echo $this->table->generate();
+</code>
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;<a href="ftp.html">&nbsp;FTP Class</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="image_lib.html">Image Manipulation Class</a>
+</p>
+<p><a href="http://www.codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2007 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">Ellislab, Inc.</a></p>
+</div>
+
+</body>
+</html> \ No newline at end of file
diff --git a/user_guide/libraries/trackback.html b/user_guide/libraries/trackback.html
index a971cb0c9..096e16ac2 100644
--- a/user_guide/libraries/trackback.html
+++ b/user_guide/libraries/trackback.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/libraries/unit_testing.html b/user_guide/libraries/unit_testing.html
index e2f1d114b..1f37649c3 100644
--- a/user_guide/libraries/unit_testing.html
+++ b/user_guide/libraries/unit_testing.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/libraries/uri.html b/user_guide/libraries/uri.html
index 4b71480bb..2306d82ad 100644
--- a/user_guide/libraries/uri.html
+++ b/user_guide/libraries/uri.html
@@ -1 +1,252 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>CodeIgniter User Guide : URI Class</title> <style type='text/css' media='all'>@import url('../userguide.css');</style> <link rel='stylesheet' type='text/css' media='all' href='../userguide.css' /> <script type="text/javascript" src="../nav/nav.js"></script> <script type="text/javascript" src="../nav/prototype.lite.js"></script> <script type="text/javascript" src="../nav/moo.fx.js"></script> <script type="text/javascript" src="../nav/user_guide_menu.js"></script> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv='expires' content='-1' /> <meta http-equiv= 'pragma' content='no-cache' /> <meta name='robots' content='all' /> <meta name='author' content='Rick Ellis' /> <meta name='description' content='CodeIgniter User Guide' /> </head> <body> <!-- START NAVIGATION --> <div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div> <div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle.jpg" width="153" height="44" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div> <div id="masthead"> <table cellpadding="0" cellspacing="0" border="0" style="width:100%"> <tr> <td><h1>CodeIgniter User Guide Version 1.5.4</h1></td> <td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td> </tr> </table> </div> <!-- END NAVIGATION --> <!-- START BREADCRUMB --> <table cellpadding="0" cellspacing="0" border="0" style="width:100%"> <tr> <td id="breadcrumb"> <a href="http://www.codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp; <a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp; URI Class </td> <td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td> </tr> </table> <!-- END BREADCRUMB --> <br clear="all" /> <!-- START CONTENT --> <div id="content"> <h1>URI Class</h1> <p>The URI Class provides functions that help you retrieve information from your URI strings. If you use URI routing, you can also retrieve information about the re-routed segments.</p> <p class="important"><strong>Note:</strong> This class is initialized automatically by the system so there is no need to do it manually.</p> <h2>$this->uri->segment(<var>n</var>)</h2> <p>Permits you to retrieve a specific segment. Where <var>n</var> is the segment number you wish to retrieve. Segments are numbered from left to right. For example, if your full URL is this:</p> <code>http://www.your-site.com/index.php/news/local/metro/crime_is_up</code> <p>The segment numbers would be this:</p> <ol> <li>news</li> <li>local</li> <li>metro</li> <li>crime_is_up</li> </ol> <p>By default the function returns FALSE (boolean) if the segment does not exist. There is an optional second parameter that permits you to set your own default value if the segment is missing. For example, this would tell the function to return the number zero in the event of failure:</p> <code>$product_id = $this->uri->segment(3, 0);</code> <p>It helps avoid having to write code like this:</p> <code>if ($this->uri->segment(3) === FALSE)<br /> {<br /> &nbsp;&nbsp;&nbsp;&nbsp;$product_id = 0;<br /> }<br /> else<br /> {<br /> &nbsp;&nbsp;&nbsp;&nbsp;$product_id = $this->uri->segment(3);<br /> }<br /> </code> <h2>$this->uri->rsegment(<var>n</var>)</h2> <p>This function is identical to the previous one, except that it lets you retrieve a specific segment from your re-routed URI in the event you are using CodeIgniter's <a href="../general/routing.html">URI Routing</a> feature.</p> <h2>$this->uri->slash_segment(<var>n</var>)</h2> <p>This function is almost identical to <dfn>$this->uri->segment()</dfn>, except it adds a trailing and/or leading slash based on the second parameter. If the parameter is not used, a trailing slash added. Examples:</p> <code>$this->uri->slash_segment(<var>3</var>);<br /> $this->uri->slash_segment(<var>3</var>, 'leading');<br /> $this->uri->slash_segment(<var>3</var>, 'both');</code> <p>Returns:</p> <ol> <li>segment/</li> <li>/segment</li> <li>/segment/</li> </ol> <h2>$this->uri->slash_rsegment(<var>n</var>)</h2> <p>This function is identical to the previous one, except that it lets you add slashes a specific segment from your re-routed URI in the event you are using CodeIgniter's <a href="../general/routing.html">URI Routing</a> feature.</p> <h2>$this->uri->uri_to_assoc(<var>n</var>)</h2> <p>This function lets you turn URI segments into and associative array of key/value pairs. Consider this URI:</p> <code>index.php/user/search/name/joe/location/UK/gender/male</code> <p>Using this function you can turn the URI into an associative array with this prototype:</p> <code>[array]<br /> (<br /> &nbsp;&nbsp;&nbsp;&nbsp;'name' => 'joe'<br /> &nbsp;&nbsp;&nbsp;&nbsp;'location' => 'UK'<br /> &nbsp;&nbsp;&nbsp;&nbsp;'gender' => 'male'<br /> )</code> <p>The first parameter of the function lets you set an offset. By default it is set to <kbd>3</kbd> since your URI will normally contain a controller/function in the first and second segments. Example:</p> <code> $array = $this->uri->uri_to_assoc(3);<br /> <br /> echo $array['name']; </code> <p>The second parameter lets you set default key names, so that the array returned by the function will always contain expected indexes, even if missing from the URI. Example:</p> <code> $default = array('name', 'gender', 'location', 'type', 'sort');<br /> <br /> $array = $this->uri->uri_to_assoc(3, $default);</code> <p>If the URI does not contain a value in your default, an array index will be set to that name, with a value of FALSE.</p> <p>Lastly, if a corresponding value is not found for a given key (if there is an odd number of URI segments) the value will be set to FALSE (boolean).</p> <h2>$this->uri->ruri_to_assoc(<var>n</var>)</h2> <p>This function is identical to the previous one, except that it creates an associative array using the re-routed URI in the event you are using CodeIgniter's <a href="../general/routing.html">URI Routing</a> feature.</p> <h2>$this->uri->assoc_to_uri()</h2> <p>Takes an associative array as input and generates a URI string from it. The array keys will be included in the string. Example:</p> <code>$array = array('product' => 'shoes', 'size' => 'large', 'color' => 'red');<br /> <br /> $str = $this->uri->assoc_to_uri($array);<br /> <br /> // Produces: product/shoes/size/large/color/red </code> <h2>$this->uri->uri_string()</h2> <p>Returns a string with the complete URI. For example, if this is your full URL:</p> <code>http://www.your-site.com/index.php/news/local/345</code> <p>The function would return this:</p> <code>/news/local/345</code> <h2>$this->uri->ruri_string(<var>n</var>)</h2> <p>This function is identical to the previous one, except that it returns the re-routed URI in the event you are using CodeIgniter's <a href="../general/routing.html">URI Routing</a> feature.</p> <h2>$this->uri->total_segments()</h2> <p>Returns the total number of segments.</p> <h2>$this->uri->total_rsegments(<var>n</var>)</h2> <p>This function is identical to the previous one, except that it returns the total number of segments in your re-routed URI in the event you are using CodeIgniter's <a href="../general/routing.html">URI Routing</a> feature.</p> <h2>$this->uri->segment_array()</h2> <p>Returns an array containing the URI segments. For example:</p> <code> $segs = $this->uri->segment_array();<br /> <br /> foreach ($segs as $segment)<br /> {<br /> &nbsp;&nbsp;&nbsp;&nbsp;echo $segment;<br /> &nbsp;&nbsp;&nbsp;&nbsp;echo '&lt;br />';<br /> }</code> <h2>$this->uri->rsegment_array(<var>n</var>)</h2> <p>This function is identical to the previous one, except that it returns the array of segments in your re-routed URI in the event you are using CodeIgniter's <a href="../general/routing.html">URI Routing</a> feature. </div> <!-- END CONTENT --> <div id="footer"> <p> Previous Topic:&nbsp;&nbsp;<a href="unit_testing.html">Unit Testing Class</a> &nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp; <a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp; <a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp; Next Topic:&nbsp;&nbsp;<a href="user_agent.html">User Agent Class</a> </p> <p><a href="http://www.codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2007 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">Ellislab, Inc.</a></p> </div> </body> </html> \ No newline at end of file
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html>
+<head>
+
+<title>CodeIgniter User Guide : URI Class</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='Rick Ellis' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle.jpg" width="153" height="44" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://www.codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+URI Class
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+
+<h1>URI Class</h1>
+
+<p>The URI Class provides functions that help you retrieve information from your URI strings. If you use URI routing, you can
+also retrieve information about the re-routed segments.</p>
+
+<p class="important"><strong>Note:</strong> This class is initialized automatically by the system so there is no need to do it manually.</p>
+
+<h2>$this->uri->segment(<var>n</var>)</h2>
+
+<p>Permits you to retrieve a specific segment. Where <var>n</var> is the segment number you wish to retrieve.
+Segments are numbered from left to right. For example, if your full URL is this:</p>
+
+<code>http://www.your-site.com/index.php/news/local/metro/crime_is_up</code>
+
+<p>The segment numbers would be this:</p>
+
+<ol>
+<li>news</li>
+<li>local</li>
+<li>metro</li>
+<li>crime_is_up</li>
+</ol>
+
+<p>By default the function returns FALSE (boolean) if the segment does not exist. There is an optional second parameter that
+permits you to set your own default value if the segment is missing.
+For example, this would tell the function to return the number zero in the event of failure:</p>
+
+<code>$product_id = $this->uri->segment(3, 0);</code>
+
+<p>It helps avoid having to write code like this:</p>
+
+<code>if ($this->uri->segment(3) === FALSE)<br />
+{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;$product_id = 0;<br />
+}<br />
+else<br />
+{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;$product_id = $this->uri->segment(3);<br />
+}<br />
+</code>
+
+<h2>$this->uri->rsegment(<var>n</var>)</h2>
+
+<p>This function is identical to the previous one, except that it lets you retrieve a specific segment from your
+re-routed URI in the event you are using CodeIgniter's <a href="../general/routing.html">URI Routing</a> feature.</p>
+
+
+<h2>$this->uri->slash_segment(<var>n</var>)</h2>
+
+<p>This function is almost identical to <dfn>$this->uri->segment()</dfn>, except it adds a trailing and/or leading slash based on the second
+parameter. If the parameter is not used, a trailing slash added. Examples:</p>
+
+<code>$this->uri->slash_segment(<var>3</var>);<br />
+$this->uri->slash_segment(<var>3</var>, 'leading');<br />
+$this->uri->slash_segment(<var>3</var>, 'both');</code>
+
+<p>Returns:</p>
+
+<ol>
+<li>segment/</li>
+<li>/segment</li>
+<li>/segment/</li>
+</ol>
+
+
+<h2>$this->uri->slash_rsegment(<var>n</var>)</h2>
+
+<p>This function is identical to the previous one, except that it lets you add slashes a specific segment from your
+re-routed URI in the event you are using CodeIgniter's <a href="../general/routing.html">URI Routing</a> feature.</p>
+
+
+
+<h2>$this->uri->uri_to_assoc(<var>n</var>)</h2>
+
+<p>This function lets you turn URI segments into and associative array of key/value pairs. Consider this URI:</p>
+
+<code>index.php/user/search/name/joe/location/UK/gender/male</code>
+
+<p>Using this function you can turn the URI into an associative array with this prototype:</p>
+
+<code>[array]<br />
+(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;'name' => 'joe'<br />
+&nbsp;&nbsp;&nbsp;&nbsp;'location' => 'UK'<br />
+&nbsp;&nbsp;&nbsp;&nbsp;'gender' => 'male'<br />
+)</code>
+
+<p>The first parameter of the function lets you set an offset. By default it is set to <kbd>3</kbd> since your
+URI will normally contain a controller/function in the first and second segments. Example:</p>
+
+<code>
+$array = $this->uri->uri_to_assoc(3);<br />
+<br />
+echo $array['name'];
+</code>
+
+
+<p>The second parameter lets you set default key names, so that the array returned by the function will always contain expected indexes, even if missing from the URI. Example:</p>
+
+<code>
+$default = array('name', 'gender', 'location', 'type', 'sort');<br />
+<br />
+$array = $this->uri->uri_to_assoc(3, $default);</code>
+
+<p>If the URI does not contain a value in your default, an array index will be set to that name, with a value of FALSE.</p>
+
+<p>Lastly, if a corresponding value is not found for a given key (if there is an odd number of URI segments) the value will be set to FALSE (boolean).</p>
+
+
+<h2>$this->uri->ruri_to_assoc(<var>n</var>)</h2>
+
+<p>This function is identical to the previous one, except that it creates an associative array using the
+re-routed URI in the event you are using CodeIgniter's <a href="../general/routing.html">URI Routing</a> feature.</p>
+
+
+<h2>$this->uri->assoc_to_uri()</h2>
+
+<p>Takes an associative array as input and generates a URI string from it. The array keys will be included in the string. Example:</p>
+
+<code>$array = array('product' => 'shoes', 'size' => 'large', 'color' => 'red');<br />
+<br />
+$str = $this->uri->assoc_to_uri($array);<br />
+<br />
+// Produces: product/shoes/size/large/color/red
+</code>
+
+
+<h2>$this->uri->uri_string()</h2>
+
+<p>Returns a string with the complete URI. For example, if this is your full URL:</p>
+
+<code>http://www.your-site.com/index.php/news/local/345</code>
+
+<p>The function would return this:</p>
+
+<code>/news/local/345</code>
+
+
+<h2>$this->uri->ruri_string(<var>n</var>)</h2>
+
+<p>This function is identical to the previous one, except that it returns the
+re-routed URI in the event you are using CodeIgniter's <a href="../general/routing.html">URI Routing</a> feature.</p>
+
+
+
+<h2>$this->uri->total_segments()</h2>
+
+<p>Returns the total number of segments.</p>
+
+
+<h2>$this->uri->total_rsegments(<var>n</var>)</h2>
+
+<p>This function is identical to the previous one, except that it returns the total number of segments in your
+re-routed URI in the event you are using CodeIgniter's <a href="../general/routing.html">URI Routing</a> feature.</p>
+
+
+
+<h2>$this->uri->segment_array()</h2>
+
+<p>Returns an array containing the URI segments. For example:</p>
+
+<code>
+$segs = $this->uri->segment_array();<br />
+<br />
+foreach ($segs as $segment)<br />
+{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;echo $segment;<br />
+&nbsp;&nbsp;&nbsp;&nbsp;echo '&lt;br />';<br />
+}</code>
+
+<h2>$this->uri->rsegment_array(<var>n</var>)</h2>
+
+<p>This function is identical to the previous one, except that it returns the array of segments in your
+re-routed URI in the event you are using CodeIgniter's <a href="../general/routing.html">URI Routing</a> feature.
+
+
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="unit_testing.html">Unit Testing Class</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="user_agent.html">User Agent Class</a>
+</p>
+<p><a href="http://www.codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2007 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">Ellislab, Inc.</a></p>
+</div>
+
+</body>
+</html> \ No newline at end of file
diff --git a/user_guide/libraries/user_agent.html b/user_guide/libraries/user_agent.html
index 7dc747ef6..ab37935ec 100644
--- a/user_guide/libraries/user_agent.html
+++ b/user_guide/libraries/user_agent.html
@@ -1 +1,201 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>CodeIgniter User Guide : User Agent Class</title> <style type='text/css' media='all'>@import url('../userguide.css');</style> <link rel='stylesheet' type='text/css' media='all' href='../userguide.css' /> <script type="text/javascript" src="../nav/nav.js"></script> <script type="text/javascript" src="../nav/prototype.lite.js"></script> <script type="text/javascript" src="../nav/moo.fx.js"></script> <script type="text/javascript" src="../nav/user_guide_menu.js"></script> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv='expires' content='-1' /> <meta http-equiv= 'pragma' content='no-cache' /> <meta name='robots' content='all' /> <meta name='author' content='Rick Ellis' /> <meta name='description' content='CodeIgniter User Guide' /> </head> <body> <!-- START NAVIGATION --> <div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div> <div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle.jpg" width="153" height="44" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div> <div id="masthead"> <table cellpadding="0" cellspacing="0" border="0" style="width:100%"> <tr> <td><h1>CodeIgniter User Guide Version 1.5.4</h1></td> <td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td> </tr> </table> </div> <!-- END NAVIGATION --> <!-- START BREADCRUMB --> <table cellpadding="0" cellspacing="0" border="0" style="width:100%"> <tr> <td id="breadcrumb"> <a href="http://www.codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp; <a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp; User Agent Class </td> <td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td> </tr> </table> <!-- END BREADCRUMB --> <br clear="all" /> <!-- START CONTENT --> <div id="content"> <h1>User Agent Class</h1> <p>The User Agent Class provides functions that help identify information about the browser, mobile device, or robot visiting your site. In addition you can get referrer information as well as language and supported character-set information.</p> <h2>Initializing the Class</h2> <p>Like most other classes in CodeIgniter, the User Agent class is initialized in your controller using the <dfn>$this->load->library</dfn> function:</p> <code>$this->load->library('user_agent');</code> <p>Once loaded, the object will be available using: <dfn>$this->agent</dfn></p> <h2>User Agent Definitions</h2> <p>The user agent name definitions are located in a config file located at: <dfn>application/config/user_agents.php</dfn>. You may add items to the various user agent arrays if needed.</p> <h2>Example</h2> <p>When the User Agent class is initialized it will attempt to determine whether the user agent browsing your site is a web browser, a mobile device, or a robot. It will also gather the platform information if it is available.</p> <code> $this->load->library('user_agent');<br /> <br /> if ($this->agent->is_browser())<br /> {<br /> &nbsp;&nbsp;&nbsp;&nbsp;$agent = $this->agent->browser().' '.$this->agent->version();<br /> }<br /> elseif ($this->agent->is_robot())<br /> {<br /> &nbsp;&nbsp;&nbsp;&nbsp;$agent = $this->agent->robot();<br /> }<br /> elseif ($this->agent->is_mobile())<br /> {<br /> &nbsp;&nbsp;&nbsp;&nbsp;$agent = $this->agent->mobile();<br /> }<br /> else<br /> {<br /> &nbsp;&nbsp;&nbsp;&nbsp;$agent = 'Unidentified User Agent';<br /> }<br /> <br /> echo $agent;<br /> <br /> echo $this->agent->platform(); // Platform info (Windows, Linux, Mac, etc.) </code> <h1>Function Reference</h1> <h2>$this->agent->is_browser()</h2> <p>Returns TRUE/FALSE (boolean) if the user agent is a known web browser.</p> <h2>$this->agent->is_mobile()</h2> <p>Returns TRUE/FALSE (boolean) if the user agent is a known mobile device.</p> <h2>$this->agent->is_robot()</h2> <p>Returns TRUE/FALSE (boolean) if the user agent is a known robot.</p> <p class="important"><strong>Note:</strong>&nbsp; The user agent library only contains the most common robot definitions. It is not a complete list of bots. There are hundreds of them so searching for each one would not be very efficient. If you find that some bots that commonly visit your site are missing from the list you can add them to your <dfn>application/config/user_agents.php</dfn> file.</p> <h2>$this->agent->is_referral()</h2> <p>Returns TRUE/FALSE (boolean) if the user agent was referred from another site.</p> <h2>$this->agent->browser()</h2> <p>Returns a string containing the name of the web browser viewing your site.</p> <h2>$this->agent->version()</h2> <p>Returns a string containing the version number of the web browser viewing your site.</p> <h2>$this->agent->mobile()</h2> <p>Returns a string containing the name of the mobile device viewing your site.</p> <h2>$this->agent->robot()</h2> <p>Returns a string containing the name of the robot viewing your site.</p> <h2>$this->agent->platform()</h2> <p>Returns a string containing the platform viewing your site (Linux, Windows, OS X, etc.).</p> <h2>$this->agent->referrer()</h2> <p>The referrer, if the user agent was referred from another site. Typically you'll test for this as follows:</p> <code> if ($this->agent->is_referral())<br /> {<br /> &nbsp;&nbsp;&nbsp;&nbsp;echo $this->agent->referrer();<br /> }</code> <h2>$this->agent->agent_string()</h2> <p>Returns a string containing the full user agent string. Typically it will be something like this:</p> <code>Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.0.4) Gecko/20060613 Camino/1.0.2</code> <h2>$this->agent->accept_lang()</h2> <p>Lets you determine if the user agent accepts a particular language. Example:</p> <code>if ($this->agent->accept_lang('en'))<br /> {<br /> &nbsp;&nbsp;&nbsp;&nbsp;echo 'You accept English!';<br /> }</code> <p class="important"><strong>Note:</strong> This function is not typically very reliable since some browsers do not provide language info, and even among those that do, it is not always accurate. </p> <h2>$this->agent->accept_charset()</h2> <p>Lets you determine if the user agent accepts a particular character set. Example:</p> <code>if ($this->agent->accept_charset('utf-8'))<br /> {<br /> &nbsp;&nbsp;&nbsp;&nbsp;echo 'You browser supports UTF-8!';<br /> }</code> <p class="important"><strong>Note:</strong> This function is not typically very reliable since some browsers do not provide character-set info, and even among those that do, it is not always accurate. </p> </div> <!-- END CONTENT --> <div id="footer"> <p> Previous Topic:&nbsp;&nbsp;<a href="uri.html">URI Class</a> &nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp; <a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp; <a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp; Next Topic:&nbsp;&nbsp;<a href="validation.html">Validation Class</a> </p> <p><a href="http://www.codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2007 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">Ellislab, Inc.</a></p> </div> </body> </html> \ No newline at end of file
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html>
+<head>
+
+<title>CodeIgniter User Guide : User Agent Class</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='Rick Ellis' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle.jpg" width="153" height="44" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://www.codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+User Agent Class
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+
+<h1>User Agent Class</h1>
+
+<p>The User Agent Class provides functions that help identify information about the browser, mobile device, or robot visiting your site.
+In addition you can get referrer information as well as language and supported character-set information.</p>
+
+<h2>Initializing the Class</h2>
+
+<p>Like most other classes in CodeIgniter, the User Agent class is initialized in your controller using the <dfn>$this->load->library</dfn> function:</p>
+
+<code>$this->load->library('user_agent');</code>
+<p>Once loaded, the object will be available using: <dfn>$this->agent</dfn></p>
+
+<h2>User Agent Definitions</h2>
+
+<p>The user agent name definitions are located in a config file located at: <dfn>application/config/user_agents.php</dfn>. You may add items to the
+various user agent arrays if needed.</p>
+
+<h2>Example</h2>
+
+<p>When the User Agent class is initialized it will attempt to determine whether the user agent browsing your site is
+a web browser, a mobile device, or a robot. It will also gather the platform information if it is available.</p>
+
+
+<code>
+$this->load->library('user_agent');<br />
+<br />
+if ($this->agent->is_browser())<br />
+{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;$agent = $this->agent->browser().' '.$this->agent->version();<br />
+}<br />
+elseif ($this->agent->is_robot())<br />
+{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;$agent = $this->agent->robot();<br />
+}<br />
+elseif ($this->agent->is_mobile())<br />
+{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;$agent = $this->agent->mobile();<br />
+}<br />
+else<br />
+{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;$agent = 'Unidentified User Agent';<br />
+}<br />
+<br />
+echo $agent;<br />
+<br />
+echo $this->agent->platform(); // Platform info (Windows, Linux, Mac, etc.)
+</code>
+
+
+<h1>Function Reference</h1>
+
+
+<h2>$this->agent->is_browser()</h2>
+<p>Returns TRUE/FALSE (boolean) if the user agent is a known web browser.</p>
+
+<h2>$this->agent->is_mobile()</h2>
+<p>Returns TRUE/FALSE (boolean) if the user agent is a known mobile device.</p>
+
+<h2>$this->agent->is_robot()</h2>
+<p>Returns TRUE/FALSE (boolean) if the user agent is a known robot.</p>
+
+<p class="important"><strong>Note:</strong>&nbsp; The user agent library only contains the most common robot
+definitions. It is not a complete list of bots. There are hundreds of them so searching for each one would not be
+very efficient. If you find that some bots that commonly visit your site are missing from the list you can add them to your
+<dfn>application/config/user_agents.php</dfn> file.</p>
+
+<h2>$this->agent->is_referral()</h2>
+<p>Returns TRUE/FALSE (boolean) if the user agent was referred from another site.</p>
+
+
+<h2>$this->agent->browser()</h2>
+<p>Returns a string containing the name of the web browser viewing your site.</p>
+
+<h2>$this->agent->version()</h2>
+<p>Returns a string containing the version number of the web browser viewing your site.</p>
+
+<h2>$this->agent->mobile()</h2>
+<p>Returns a string containing the name of the mobile device viewing your site.</p>
+
+<h2>$this->agent->robot()</h2>
+<p>Returns a string containing the name of the robot viewing your site.</p>
+
+<h2>$this->agent->platform()</h2>
+<p>Returns a string containing the platform viewing your site (Linux, Windows, OS X, etc.).</p>
+
+<h2>$this->agent->referrer()</h2>
+<p>The referrer, if the user agent was referred from another site. Typically you'll test for this as follows:</p>
+
+<code> if ($this->agent->is_referral())<br />
+{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;echo $this->agent->referrer();<br />
+}</code>
+
+
+<h2>$this->agent->agent_string()</h2>
+<p>Returns a string containing the full user agent string. Typically it will be something like this:</p>
+
+<code>Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.0.4) Gecko/20060613 Camino/1.0.2</code>
+
+
+<h2>$this->agent->accept_lang()</h2>
+<p>Lets you determine if the user agent accepts a particular language. Example:</p>
+
+<code>if ($this->agent->accept_lang('en'))<br />
+{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;echo 'You accept English!';<br />
+}</code>
+
+<p class="important"><strong>Note:</strong> This function is not typically very reliable
+since some browsers do not provide language info, and even among those that do, it is not always accurate. </p>
+
+
+
+<h2>$this->agent->accept_charset()</h2>
+<p>Lets you determine if the user agent accepts a particular character set. Example:</p>
+
+<code>if ($this->agent->accept_charset('utf-8'))<br />
+{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;echo 'You browser supports UTF-8!';<br />
+}</code>
+
+<p class="important"><strong>Note:</strong> This function is not typically very reliable
+since some browsers do not provide character-set info, and even among those that do, it is not always accurate. </p>
+
+
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="uri.html">URI Class</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="validation.html">Validation Class</a>
+</p>
+<p><a href="http://www.codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2007 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">Ellislab, Inc.</a></p>
+</div>
+
+</body>
+</html> \ No newline at end of file
diff --git a/user_guide/libraries/validation.html b/user_guide/libraries/validation.html
index 90ff0c127..30de0fd2b 100644
--- a/user_guide/libraries/validation.html
+++ b/user_guide/libraries/validation.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/libraries/xmlrpc.html b/user_guide/libraries/xmlrpc.html
index cd2f9e306..039127913 100644
--- a/user_guide/libraries/xmlrpc.html
+++ b/user_guide/libraries/xmlrpc.html
@@ -1 +1,487 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>CodeIgniter User Guide : XML-RPC and XML-RPC Server Classes</title> <style type='text/css' media='all'>@import url('../userguide.css');</style> <link rel='stylesheet' type='text/css' media='all' href='../userguide.css' /> <script type="text/javascript" src="../nav/nav.js"></script> <script type="text/javascript" src="../nav/prototype.lite.js"></script> <script type="text/javascript" src="../nav/moo.fx.js"></script> <script type="text/javascript" src="../nav/user_guide_menu.js"></script> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv='expires' content='-1' /> <meta http-equiv= 'pragma' content='no-cache' /> <meta name='robots' content='all' /> <meta name='author' content='Rick Ellis' /> <meta name='description' content='CodeIgniter User Guide' /> </head> <body> <!-- START NAVIGATION --> <div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div> <div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle.jpg" width="153" height="44" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div> <div id="masthead"> <table cellpadding="0" cellspacing="0" border="0" style="width:100%"> <tr> <td><h1>CodeIgniter User Guide Version 1.5.4</h1></td> <td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td> </tr> </table> </div> <!-- END NAVIGATION --> <!-- START BREADCRUMB --> <table cellpadding="0" cellspacing="0" border="0" style="width:100%"> <tr> <td id="breadcrumb"> <a href="http://www.codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp; <a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp; XML-RPC and XML-RPC Server Classes </td> <td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td> </tr> </table> <!-- END BREADCRUMB --> <br clear="all" /> <!-- START CONTENT --> <div id="content"> <h1>XML-RPC and XML-RPC Server Classes</h1> <p>CodeIgniter's XML-RPC classes permit you to send requests to another server, or set up your own XML-RPC server to receive requests.</p> <h2>What is XML-RPC?</h2> <p>Quite simply it is a way for two computers to communicate over the internet using XML. One computer, which we will call the <dfn>client</dfn>, sends an XML-RPC <strong>request</strong> to another computer, which we will call the <dfn>server</dfn>. Once the server receives and processes the request it will send back a <strong>response</strong> to the client.</p> <p>For example, using the MetaWeblog API, an XML-RPC Client (usually a desktop publishing tool) will send a request to an XML-RPC Server running on your site. This request might be a new weblog entry being sent for publication, or it could be a request for an existing entry for editing. When the XML-RPC Server receives this request it will examine it to determine which class/method should be called to process the request. Once processed, the server will then send back a response message.</p> <p>For detailed specifications, you can visit the <a href="http://www.xmlrpc.com/">XML-RPC</a> site.</p> <h2>Initializing the Class</h2> <p>Like most other classes in CodeIgniter, the XML-RPC and XML-RPCS classes are initialized in your controller using the <dfn>$this->load->library</dfn> function:</p> <p>To load the XML-RPC class you will use:</p> <code>$this->load->library('xmlrpc');</code> <p>Once loaded, the xml-rpc library object will be available using: <dfn>$this->xmlrpc</dfn></p> <p>To load the XML-RPC Server class you will use:</p> <code> $this->load->library('xmlrpc');<br /> $this->load->library('xmlrpcs'); </code> <p>Once loaded, the xml-rpcs library object will be available using: <dfn>$this->xmlrpcs</dfn></p> <p class="important"><strong>Note:</strong>&nbsp; When using the XML-RPC Server class you must load BOTH the XML-RPC class and the XML-RPC Server class.</p> <h2>Sending XML-RPC Requests</h2> <p>To send a request to an XML-RPC server you must specify the following information:</p> <ul> <li>The URL of the server</li> <li>The method on the server you wish to call</li> <li>The <em>request</em> data (explained below).</li> </ul> <p>Here is a basic example that sends a simple Weblogs.com ping to the <a href="http://pingomatic.com/">Ping-o-Matic</a></p> <code>$this->load->library('xmlrpc');<br /> <br /> $this->xmlrpc->server('http://rpc.pingomatic.com/', 80);<br /> $this->xmlrpc->method('weblogUpdates.ping');<br /> <br /> $request = array('My Photoblog', 'http://www.my-site.com/photoblog/');<br /> $this->xmlrpc->request($request);<br /> <br /> if ( ! $this->xmlrpc->send_request())<br /> {<br /> &nbsp;&nbsp;&nbsp;&nbsp;echo $this-&gt;xmlrpc->display_error();<br /> }</code> <h3>Explanation</h3> <p>The above code initializes the XML-RPC class, sets the server URL and method to be called (weblogUpdates.ping). The request (in this case, the title and URL of your site) is placed into an array for transportation, and compiled using the request() function. Lastly, the full request is sent. If the <dfn>send_request()</dfn> method returns false we will display the error message sent back from the XML-RPC Server.</p> <h2>Anatomy of a Request</h2> <p>An XML-RPC <dfn>request</dfn> is simply the data you are sending to the XML-RPC server. Each piece of data in a request is referred to as a <dfn>request parameter</dfn>. The above example has two parameters: The URL and title of your site. When the XML-RPC server receives your request, it will look for parameters it requires.</p> <p>Request parameters must be placed into an array for transportation, and each parameter can be one of seven data types (strings, numbers, dates, etc.). If your parameters are something other than strings you will have to include the data type in the request array.</p> <p>Here is an example of a simple array with three parameters:</p> <code>$request = array('John', 'Doe', 'www.some-site.com');<br /> $this->xmlrpc->request($request);</code> <p>If you use data types other than strings, or if you have several different data types, you will place each parameter into its own array, with the data type in the second position:</p> <code> $request = array (<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array('John', 'string'),<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array('Doe', 'string'),<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array(FALSE, 'boolean'),<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array(12345, 'int')<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;); <br /> $this->xmlrpc->request($request);</code> The <a href="#datatypes">Data Types</a> section below has a full list of data types. <h2>Creating an XML-RPC Server</h2> <p>An XML-RPC Server acts as a traffic cop of sorts, waiting for incoming requests and redirecting them to the appropriate functions for processing.</p> <p>To create your own XML-RPC server involves initializing the XML-RPC Server class in your controller where you expect the incoming request to appear, then setting up an array with mapping instructions so that incoming requests can be sent to the appropriate class and method for processing.</p> <p>Here is an example to illustrate:</p> <code> $this->load->library('xmlrpc');<br /> $this->load->library('xmlrpcs');<br /> <br /> $config['functions']['<var>new_post</var>']&nbsp;&nbsp;= array('function' => '<dfn>My_blog.new_entry</dfn>');<br /> $config['functions']['<var>update_post</var>'] = array('function' => '<dfn>My_blog.update_entry</dfn>');<br /> <br /> $this->xmlrpcs->initialize($config);<br /> $this->xmlrpcs->serve();</code> <p>The above example contains an array specifying two method requests that the Server allows. The allowed methods are on the left side of the array. When either of those are received, they will be mapped to the class and method on the right.</p> <p>In other words, if an XML-RPC Client sends a request for the <var>new_post</var> method, your server will load the <dfn>My_blog</dfn> class and call the <dfn>new_entry</dfn> function. If the request is for the <var>update_post</var> method, your server will load the <dfn>My_blog</dfn> class and call the <dfn>update_entry</dfn> function.</p> <p>The function names in the above example are arbitrary. You'll decide what they should be called on your server, or if you are using standardized APIs, like the Blogger or MetaWeblog API, you'll use their function names.</p> <h2>Processing Server Requests</h2> <p>When the XML-RPC Server receives a request and loads the class/method for processing, it will pass an object to that method containing the data sent by the client.</p> <p>Using the above example, if the <var>new_post</var> method is requested, the server will expect a class to exist with this prototype:</p> <code>class <kbd>My_blog</kbd> extends Controller {<br /> <br /> &nbsp;&nbsp;&nbsp;&nbsp;function <kbd>new_post</kbd>(<var>$request</var>)<br /> &nbsp;&nbsp;&nbsp;&nbsp;{<br /> <br /> &nbsp;&nbsp;&nbsp;&nbsp;}<br /> } </code> <p>The <var>$request</var> variable is an object compiled by the Server, which contains the data sent by the XML-RPC Client. Using this object you will have access to the <em>request parameters</em> enabling you to process the request. When you are done you will send a <dfn>Response</dfn> back to the Client.</p> <p>Below is a real-world example, using the Blogger API. One of the methods in the Blogger API is <dfn>getUserInfo()</dfn>. Using this method, an XML-RPC Client can send the Server a username and password, in return the Server sends back information about that particular user (nickname, user ID, email address, etc.). Here is how the processing function might look:</p> <code>class <kbd>My_blog</kbd> extends Controller {<br /> <br /> &nbsp;&nbsp;&nbsp;&nbsp;function <kbd>getUserInfo</kbd>(<var>$request</var>)<br /> &nbsp;&nbsp;&nbsp;&nbsp;{<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$username = 'smitty';<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$password = 'secretsmittypass';<br /><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this->load->library('xmlrpc');<br /> &nbsp;&nbsp;&nbsp;&nbsp;<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$parameters&nbsp;=&nbsp;$request->output_parameters();<br /> &nbsp;&nbsp;&nbsp;&nbsp;<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;($parameters['1'] != $username AND $parameters['2'] != $password)<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;$this->xmlrpc->send_error_message('100',&nbsp;'Invalid&nbsp;Access');<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br /> &nbsp;&nbsp;&nbsp;&nbsp;<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$response&nbsp;=&nbsp;array(array('nickname'&nbsp;&nbsp;=>&nbsp;array('Smitty','string'),<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'userid'&nbsp;&nbsp;&nbsp;&nbsp;=>&nbsp;array('99','string'),<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'url'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=>&nbsp;array('http://yoursite.com','string'),<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'email'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=>&nbsp;array('jsmith@yoursite.com','string'),<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'lastname'&nbsp;&nbsp;=>&nbsp;array('Smith','string'),<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'firstname'&nbsp;=>&nbsp;array('John','string')<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;),<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'struct');<br /> <br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return $this->xmlrpc->send_response($response);<br /> &nbsp;&nbsp;&nbsp;&nbsp;}<br /> } </code> <h3>Notes:</h3> <p>The <dfn>output_parameters()</dfn> function retrieves an indexed array corresponding to the request parameters sent by the client. In the above example, the output parameters will be the username and password.</p> <p>If the username and password sent by the client were not valid, and error message is returned using <dfn>send_error_message()</dfn>.</p> <p>If the operation was successful, the client will be sent back a response array containing the user's info.</p> <h2>Formatting a Response</h2> <p>Similar to <em>Requests</em>, <em>Responses</em> must be formatted as an array. However, unlike requests, a response is an array <strong>that contains a single item</strong>. This item can be an array with several additional arrays, but there can be only one primary array index. In other words, the basic prototype is this:</p> <code>$response = array('Response data', 'array');</code> <p>Responses, however, usually contain multiple pieces of information. In order to accomplish this we must put the response into its own array so that the primary array continues to contain a single piece of data. Here's an example showing how this might be accomplished:</p> <code> $response = array (<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array(<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'first_name' => array('John', 'string'),<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'last_name' => array('Doe', 'string'),<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'member_id' => array(123435, 'int'),<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'todo_list' => array(array('clean house', 'call mom', 'water plants'), 'array'),<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;),<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'struct'<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;); </code> <p class="important">Notice that the above array is formatted as a <dfn>struct</dfn>. This is the most common data type for responses.</p> <p>As with Requests, a response can be on of the seven data types listed in the <a href="#datatypes">Data Types</a> section.</p> <h2>Sending an Error Response</h2> <p>If you need to send the client an error response you will use the following:</p> <code>return $this->xmlrpc->send_error_message('123', 'Requested data not available');</code> <p>The first parameter is the error number while the second parameter is the error message.</p> <h2>Creating Your Own Client and Server</h2> <p>To help you understand everything we've covered thus far, let's create a couple controllers that act as XML-RPC Client and Server. You'll use the Client to send a request to the Server and receive a response.</p> <h3>The Client</h3> <p>Using a text editor, create a controller called <dfn>xmlrpc_client.php</dfn>. In it, place this code and save it to your <samp>applications/controllers/</samp> folder:</p> <textarea class="textarea" style="width:100%" cols="50" rows="32"><?php class Xmlrpc_client extends Controller { function index() { $this->load->helper('url'); $server_url = site_url('xmlrpc_server'); $this->load->library('xmlrpc'); $this->xmlrpc->server($server_url, 80); $this->xmlrpc->method('Greetings'); $request = array('How is it going?'); $this->xmlrpc->request($request); if ( ! $this->xmlrpc->send_request()) { echo $this->xmlrpc->display_error(); } else { echo '<pre>'; print_r($this->xmlrpc->display_response()); echo '</pre>'; } } } ?></textarea> <p>Note: In the above code we are using a "url helper". You can find more information in the <a href="../general/helpers.html">Helpers Functions</a> page.</p> <h3>The Server</h3> <p>Using a text editor, create a controller called <dfn>xmlrpc_server.php</dfn>. In it, place this code and save it to your <samp>applications/controllers/</samp> folder:</p> <textarea class="textarea" style="width:100%" cols="50" rows="30"><?php class Xmlrpc_server extends Controller { function index() { $this->load->library('xmlrpc'); $this->load->library('xmlrpcs'); $config['functions']['Greetings'] = array('function' => 'Xmlrpc_server.process'); $this->xmlrpcs->initialize($config); $this->xmlrpcs->serve(); } function process($request) { $parameters = $request->output_parameters(); $response = array( array( 'you_said' => $parameters['0'], 'i_respond' => 'Not bad at all.'), 'struct'); return $this->xmlrpc->send_response($response); } } ?></textarea> <h3>Try it!</h3> <p>Now visit the your site using a URL similar to this:</p> <code>www.your-site.com/index.php/<var>xmlrpc_client</var>/</code> <p>You should now see the message you sent to the server, and its response back to you.</p> <p>The client you created sends a message ("How's is going?") to the server, along with a reqest for the "Greetings" method. The Server receives the request and maps it to the "process" function, where a response is sent back.</p> <p>&nbsp;</p> <h1>XML-RPC Function Reference</h1> <h2>$this->xmlrpc->server()</h2> <p>Sets the URL and port number of the server to which a request is to be sent:</p> <code>$this->xmlrpc->server('http://www.sometimes.com/pings.php', 80);</code> <h2>$this->xmlrpc->timeout()</h2> <p>Set a time out period (in seconds) after which the request will be canceled:</p> <code>$this->xmlrpc->timeout(6);</code> <h2>$this->xmlrpc->method()</h2> <p>Sets the method that will be requested from the XML-RPC server:</p> <code>$this->xmlrpc->method('<var>method</var>');</code> <p>Where <var>method</var> is the name of the method.</p> <h2>$this->xmlrpc->request()</h2> <p>Takes an array of data and builds request to be sent to XML-RPC server:</p> <code>$request = array(array('My Photoblog', 'string'), 'http://www.yoursite.com/photoblog/');<br /> $this->xmlrpc->request($request);</code> <h2>$this->xmlrpc->send_request()</h2> <p>The request sending function. Returns boolean TRUE or FALSE based on success for failure, enabling it to be used conditionally.</p> <h2>$this->xmlrpc->set_debug(TRUE);</h2> <p>Enables debugging, which will display a variety of information and error data helpful during development.</p> <h2>$this->xmlrpc->display_error()</h2> <p>Returns an error message as a string if your request failed for some reason.</p> <code>echo $this->xmlrpc->display_error();</code> <h2>$this->xmlrpc->display_response()</h2> <p>Returns the response from the remote server once request is received. The response will typically be an associative array.</p> <code>$this->xmlrpc->display_response();</code> <h2>$this->xmlrpc->send_error_message()</h2> <p>This function lets you send an error message from your server to the client. First parameter is the error number while the second parameter is the error message.</p> <code>return $this->xmlrpc->send_error_message('123', 'Requested data not available');</code> <h2>$this->xmlrpc->send_response()</h2> <p>Lets you send the response from your server to the client. An array of valid data values must be sent with this method.</p> <code>$response = array(<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array(<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'flerror' => array(FALSE, 'boolean'),<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'message' => "Thanks for the ping!")<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'struct');<br /> return $this->xmlrpc->send_response($response);</code> <a name="datatypes"></a> <h2>Data Types</h2> <p>According to the <a href="http://www.xmlrpc.com/spec">XML-RPC spec</a> there are seven types of values that you can send via XML-RPC:</p> <ul> <li><em>int</em> or <em>i4</em></li> <li><em>boolean</em></li> <li><em>string</em></li> <li><em>double</em></li> <li><em>dateTime.iso8601</em></li> <li><em>base64</em></li> <li><em>struct</em> (contains array of values)</li> <li><em>array</em> (contains array of values)</li> </ul> </div> <!-- END CONTENT --> <div id="footer"> <p> Previous Topic:&nbsp;&nbsp;<a href="validation.html">Validation Class</a> &nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp; <a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp; <a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp; Next Topic:&nbsp;&nbsp;<a href="zip.html">Zip Encoding Class</a> </p> <p><a href="http://www.codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2007 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">Ellislab, Inc.</a></p> </div> </body> </html> \ No newline at end of file
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html>
+<head>
+
+<title>CodeIgniter User Guide : XML-RPC and XML-RPC Server Classes</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='Rick Ellis' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle.jpg" width="153" height="44" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://www.codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+XML-RPC and XML-RPC Server Classes
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+
+<h1>XML-RPC and XML-RPC Server Classes</h1>
+
+
+<p>CodeIgniter's XML-RPC classes permit you to send requests to another server, or set up
+your own XML-RPC server to receive requests.</p>
+
+
+<h2>What is XML-RPC?</h2>
+
+<p>Quite simply it is a way for two computers to communicate over the internet using XML.
+One computer, which we will call the <dfn>client</dfn>, sends an XML-RPC <strong>request</strong> to
+another computer, which we will call the <dfn>server</dfn>. Once the server receives and processes the request it
+will send back a <strong>response</strong> to the client.</p>
+
+<p>For example, using the MetaWeblog API, an XML-RPC Client (usually a desktop publishing tool) will
+send a request to an XML-RPC Server running on your site. This request might be a new weblog entry
+being sent for publication, or it could be a request for an existing entry for editing.
+
+When the XML-RPC Server receives this request it will examine it to determine which class/method should be called to process the request.
+Once processed, the server will then send back a response message.</p>
+
+<p>For detailed specifications, you can visit the <a href="http://www.xmlrpc.com/">XML-RPC</a> site.</p>
+
+<h2>Initializing the Class</h2>
+
+<p>Like most other classes in CodeIgniter, the XML-RPC and XML-RPCS classes are initialized in your controller using the <dfn>$this->load->library</dfn> function:</p>
+
+<p>To load the XML-RPC class you will use:</p>
+<code>$this->load->library('xmlrpc');</code>
+<p>Once loaded, the xml-rpc library object will be available using: <dfn>$this->xmlrpc</dfn></p>
+
+<p>To load the XML-RPC Server class you will use:</p>
+<code>
+$this->load->library('xmlrpc');<br />
+$this->load->library('xmlrpcs');
+</code>
+<p>Once loaded, the xml-rpcs library object will be available using: <dfn>$this->xmlrpcs</dfn></p>
+
+<p class="important"><strong>Note:</strong>&nbsp; When using the XML-RPC Server class you must load BOTH the XML-RPC class and the XML-RPC Server class.</p>
+
+
+
+<h2>Sending XML-RPC Requests</h2>
+
+<p>To send a request to an XML-RPC server you must specify the following information:</p>
+
+<ul>
+<li>The URL of the server</li>
+<li>The method on the server you wish to call</li>
+<li>The <em>request</em> data (explained below).</li>
+</ul>
+
+<p>Here is a basic example that sends a simple Weblogs.com ping to the <a href="http://pingomatic.com/">Ping-o-Matic</a></p>
+
+
+<code>$this->load->library('xmlrpc');<br />
+<br />
+$this->xmlrpc->server('http://rpc.pingomatic.com/', 80);<br />
+$this->xmlrpc->method('weblogUpdates.ping');<br />
+
+<br />
+$request = array('My Photoblog', 'http://www.my-site.com/photoblog/');<br />
+$this->xmlrpc->request($request);<br />
+<br />
+if ( ! $this->xmlrpc->send_request())<br />
+{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;echo $this-&gt;xmlrpc->display_error();<br />
+}</code>
+
+<h3>Explanation</h3>
+
+<p>The above code initializes the XML-RPC class, sets the server URL and method to be called (weblogUpdates.ping). The
+request (in this case, the title and URL of your site) is placed into an array for transportation, and
+compiled using the request() function.
+Lastly, the full request is sent. If the <dfn>send_request()</dfn> method returns false we will display the error message
+sent back from the XML-RPC Server.</p>
+
+<h2>Anatomy of a Request</h2>
+
+<p>An XML-RPC <dfn>request</dfn> is simply the data you are sending to the XML-RPC server. Each piece of data in a request
+is referred to as a <dfn>request parameter</dfn>. The above example has two parameters:
+The URL and title of your site. When the XML-RPC server receives your request, it will look for parameters it requires.</p>
+
+<p>Request parameters must be placed into an array for transportation, and each parameter can be one
+of seven data types (strings, numbers, dates, etc.). If your parameters are something other than strings
+you will have to include the data type in the request array.</p>
+
+<p>Here is an example of a simple array with three parameters:</p>
+
+<code>$request = array('John', 'Doe', 'www.some-site.com');<br />
+$this->xmlrpc->request($request);</code>
+
+<p>If you use data types other than strings, or if you have several different data types, you will place
+each parameter into its own array, with the data type in the second position:</p>
+
+<code>
+$request = array (<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array('John', 'string'),<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array('Doe', 'string'),<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array(FALSE, 'boolean'),<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array(12345, 'int')<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);
+<br />
+$this->xmlrpc->request($request);</code>
+
+The <a href="#datatypes">Data Types</a> section below has a full list of data types.
+
+
+
+<h2>Creating an XML-RPC Server</h2>
+
+<p>An XML-RPC Server acts as a traffic cop of sorts, waiting for incoming requests and redirecting them to the
+appropriate functions for processing.</p>
+
+<p>To create your own XML-RPC server involves initializing the XML-RPC Server class in your controller where you expect the incoming
+request to appear, then setting up an array with mapping instructions so that incoming requests can be sent to the appropriate
+class and method for processing.</p>
+
+<p>Here is an example to illustrate:</p>
+
+<code>
+$this->load->library('xmlrpc');<br />
+$this->load->library('xmlrpcs');<br />
+<br />
+$config['functions']['<var>new_post</var>']&nbsp;&nbsp;= array('function' => '<dfn>My_blog.new_entry</dfn>');<br />
+$config['functions']['<var>update_post</var>'] = array('function' => '<dfn>My_blog.update_entry</dfn>');<br />
+<br />
+$this->xmlrpcs->initialize($config);<br />
+$this->xmlrpcs->serve();</code>
+
+<p>The above example contains an array specifying two method requests that the Server allows.
+The allowed methods are on the left side of the array. When either of those are received, they will be mapped to the class and method on the right.</p>
+
+<p>In other words, if an XML-RPC Client sends a request for the <var>new_post</var> method, your
+server will load the <dfn>My_blog</dfn> class and call the <dfn>new_entry</dfn> function.
+If the request is for the <var>update_post</var> method, your
+server will load the <dfn>My_blog</dfn> class and call the <dfn>update_entry</dfn> function.</p>
+
+<p>The function names in the above example are arbitrary. You'll decide what they should be called on your server,
+or if you are using standardized APIs, like the Blogger or MetaWeblog API, you'll use their function names.</p>
+
+
+<h2>Processing Server Requests</h2>
+
+<p>When the XML-RPC Server receives a request and loads the class/method for processing, it will pass
+an object to that method containing the data sent by the client.</p>
+
+<p>Using the above example, if the <var>new_post</var> method is requested, the server will expect a class
+to exist with this prototype:</p>
+
+<code>class <kbd>My_blog</kbd> extends Controller {<br />
+<br />
+&nbsp;&nbsp;&nbsp;&nbsp;function <kbd>new_post</kbd>(<var>$request</var>)<br />
+&nbsp;&nbsp;&nbsp;&nbsp;{<br />
+ <br />
+&nbsp;&nbsp;&nbsp;&nbsp;}<br />
+}
+</code>
+
+<p>The <var>$request</var> variable is an object compiled by the Server, which contains the data sent by the XML-RPC Client.
+Using this object you will have access to the <em>request parameters</em> enabling you to process the request. When
+you are done you will send a <dfn>Response</dfn> back to the Client.</p>
+
+<p>Below is a real-world example, using the Blogger API. One of the methods in the Blogger API is <dfn>getUserInfo()</dfn>.
+Using this method, an XML-RPC Client can send the Server a username and password, in return the Server sends
+back information about that particular user (nickname, user ID, email address, etc.). Here is how the processing
+function might look:</p>
+
+
+<code>class <kbd>My_blog</kbd> extends Controller {<br />
+<br />
+&nbsp;&nbsp;&nbsp;&nbsp;function <kbd>getUserInfo</kbd>(<var>$request</var>)<br />
+&nbsp;&nbsp;&nbsp;&nbsp;{<br />
+
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$username = 'smitty';<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$password = 'secretsmittypass';<br /><br />
+
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this->load->library('xmlrpc');<br />
+&nbsp;&nbsp;&nbsp;&nbsp;<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$parameters&nbsp;=&nbsp;$request->output_parameters();<br />
+&nbsp;&nbsp;&nbsp;&nbsp;<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;($parameters['1'] != $username AND $parameters['2'] != $password)<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;$this->xmlrpc->send_error_message('100',&nbsp;'Invalid&nbsp;Access');<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
+&nbsp;&nbsp;&nbsp;&nbsp;<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$response&nbsp;=&nbsp;array(array('nickname'&nbsp;&nbsp;=>&nbsp;array('Smitty','string'),<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'userid'&nbsp;&nbsp;&nbsp;&nbsp;=>&nbsp;array('99','string'),<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'url'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=>&nbsp;array('http://yoursite.com','string'),<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'email'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=>&nbsp;array('jsmith@yoursite.com','string'),<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'lastname'&nbsp;&nbsp;=>&nbsp;array('Smith','string'),<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'firstname'&nbsp;=>&nbsp;array('John','string')<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;),<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'struct');<br />
+<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return $this->xmlrpc->send_response($response);<br />
+&nbsp;&nbsp;&nbsp;&nbsp;}<br />
+}
+</code>
+
+<h3>Notes:</h3>
+<p>The <dfn>output_parameters()</dfn> function retrieves an indexed array corresponding to the request parameters sent by the client.
+In the above example, the output parameters will be the username and password.</p>
+
+<p>If the username and password sent by the client were not valid, and error message is returned using <dfn>send_error_message()</dfn>.</p>
+
+<p>If the operation was successful, the client will be sent back a response array containing the user's info.</p>
+
+
+<h2>Formatting a Response</h2>
+
+<p>Similar to <em>Requests</em>, <em>Responses</em> must be formatted as an array. However, unlike requests, a response is an array
+<strong>that contains a single item</strong>. This item can be an array with several additional arrays, but there
+can be only one primary array index. In other words, the basic prototype is this:</p>
+
+<code>$response = array('Response data', 'array');</code>
+
+<p>Responses, however, usually contain multiple pieces of information. In order to accomplish this we must put the response into its own
+array so that the primary array continues to contain a single piece of data. Here's an example showing how this might be accomplished:</p>
+
+<code>
+$response = array (<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'first_name' => array('John', 'string'),<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'last_name' => array('Doe', 'string'),<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'member_id' => array(123435, 'int'),<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'todo_list' => array(array('clean house', 'call mom', 'water plants'), 'array'),<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;),<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'struct'<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);
+</code>
+
+<p class="important">Notice that the above array is formatted as a <dfn>struct</dfn>. This is the most common data type for responses.</p>
+
+<p>As with Requests, a response can be on of the seven data types listed in the <a href="#datatypes">Data Types</a> section.</p>
+
+
+<h2>Sending an Error Response</h2>
+
+<p>If you need to send the client an error response you will use the following:</p>
+
+<code>return $this->xmlrpc->send_error_message('123', 'Requested data not available');</code>
+
+<p>The first parameter is the error number while the second parameter is the error message.</p>
+
+
+
+
+
+
+<h2>Creating Your Own Client and Server</h2>
+
+<p>To help you understand everything we've covered thus far, let's create a couple controllers that act as
+XML-RPC Client and Server. You'll use the Client to send a request to the Server and receive a response.</p>
+
+<h3>The Client</h3>
+
+<p>Using a text editor, create a controller called <dfn>xmlrpc_client.php</dfn>.
+In it, place this code and save it to your <samp>applications/controllers/</samp> folder:</p>
+
+<textarea class="textarea" style="width:100%" cols="50" rows="32"><?php
+
+class Xmlrpc_client extends Controller {
+
+ function index()
+ {
+ $this->load->helper('url');
+ $server_url = site_url('xmlrpc_server');
+
+ $this->load->library('xmlrpc');
+
+ $this->xmlrpc->server($server_url, 80);
+ $this->xmlrpc->method('Greetings');
+
+ $request = array('How is it going?');
+ $this->xmlrpc->request($request);
+
+ if ( ! $this->xmlrpc->send_request())
+ {
+ echo $this->xmlrpc->display_error();
+ }
+ else
+ {
+ echo '<pre>';
+ print_r($this->xmlrpc->display_response());
+ echo '</pre>';
+ }
+ }
+}
+?></textarea>
+
+<p>Note: In the above code we are using a "url helper". You can find more information in the <a href="../general/helpers.html">Helpers Functions</a> page.</p>
+
+<h3>The Server</h3>
+
+<p>Using a text editor, create a controller called <dfn>xmlrpc_server.php</dfn>.
+In it, place this code and save it to your <samp>applications/controllers/</samp> folder:</p>
+
+<textarea class="textarea" style="width:100%" cols="50" rows="30"><?php
+
+class Xmlrpc_server extends Controller {
+
+ function index()
+ {
+ $this->load->library('xmlrpc');
+ $this->load->library('xmlrpcs');
+
+ $config['functions']['Greetings'] = array('function' => 'Xmlrpc_server.process');
+
+ $this->xmlrpcs->initialize($config);
+ $this->xmlrpcs->serve();
+ }
+
+
+ function process($request)
+ {
+ $parameters = $request->output_parameters();
+
+ $response = array(
+ array(
+ 'you_said' => $parameters['0'],
+ 'i_respond' => 'Not bad at all.'),
+ 'struct');
+
+ return $this->xmlrpc->send_response($response);
+ }
+}
+?></textarea>
+
+<h3>Try it!</h3>
+
+<p>Now visit the your site using a URL similar to this:</p>
+<code>www.your-site.com/index.php/<var>xmlrpc_client</var>/</code>
+
+<p>You should now see the message you sent to the server, and its response back to you.</p>
+
+<p>The client you created sends a message ("How's is going?") to the server, along with a reqest for the "Greetings" method.
+The Server receives the request and maps it to the "process" function, where a response is sent back.</p>
+
+
+
+<p>&nbsp;</p>
+<h1>XML-RPC Function Reference</h1>
+
+<h2>$this->xmlrpc->server()</h2>
+<p>Sets the URL and port number of the server to which a request is to be sent:</p>
+<code>$this->xmlrpc->server('http://www.sometimes.com/pings.php', 80);</code>
+
+<h2>$this->xmlrpc->timeout()</h2>
+<p>Set a time out period (in seconds) after which the request will be canceled:</p>
+<code>$this->xmlrpc->timeout(6);</code>
+
+<h2>$this->xmlrpc->method()</h2>
+<p>Sets the method that will be requested from the XML-RPC server:</p>
+<code>$this->xmlrpc->method('<var>method</var>');</code>
+
+<p>Where <var>method</var> is the name of the method.</p>
+
+<h2>$this->xmlrpc->request()</h2>
+<p>Takes an array of data and builds request to be sent to XML-RPC server:</p>
+<code>$request = array(array('My Photoblog', 'string'), 'http://www.yoursite.com/photoblog/');<br />
+$this->xmlrpc->request($request);</code>
+
+<h2>$this->xmlrpc->send_request()</h2>
+<p>The request sending function. Returns boolean TRUE or FALSE based on success for failure, enabling it to be used conditionally.</p>
+
+<h2>$this->xmlrpc->set_debug(TRUE);</h2>
+<p>Enables debugging, which will display a variety of information and error data helpful during development.</p>
+
+
+<h2>$this->xmlrpc->display_error()</h2>
+<p>Returns an error message as a string if your request failed for some reason.</p>
+<code>echo $this->xmlrpc->display_error();</code>
+
+<h2>$this->xmlrpc->display_response()</h2>
+<p>Returns the response from the remote server once request is received. The response will typically be an associative array.</p>
+<code>$this->xmlrpc->display_response();</code>
+
+<h2>$this->xmlrpc->send_error_message()</h2>
+<p>This function lets you send an error message from your server to the client. First parameter is the error number while the second parameter
+is the error message.</p>
+<code>return $this->xmlrpc->send_error_message('123', 'Requested data not available');</code>
+
+<h2>$this->xmlrpc->send_response()</h2>
+<p>Lets you send the response from your server to the client. An array of valid data values must be sent with this method.</p>
+<code>$response = array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'flerror' => array(FALSE, 'boolean'),<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'message' => "Thanks for the ping!")<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'struct');<br />
+return $this->xmlrpc->send_response($response);</code>
+
+
+<a name="datatypes"></a>
+<h2>Data Types</h2>
+
+<p>According to the <a href="http://www.xmlrpc.com/spec">XML-RPC spec</a> there are seven types
+of values that you can send via XML-RPC:</p>
+
+<ul>
+<li><em>int</em> or <em>i4</em></li>
+<li><em>boolean</em></li>
+<li><em>string</em></li>
+<li><em>double</em></li>
+<li><em>dateTime.iso8601</em></li>
+<li><em>base64</em></li>
+<li><em>struct</em> (contains array of values)</li>
+<li><em>array</em> (contains array of values)</li>
+</ul>
+
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="validation.html">Validation Class</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="zip.html">Zip Encoding Class</a>
+</p>
+<p><a href="http://www.codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2007 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">Ellislab, Inc.</a></p>
+</div>
+
+</body>
+</html> \ No newline at end of file
diff --git a/user_guide/libraries/zip.html b/user_guide/libraries/zip.html
index 165d61b0c..a2ef6c42b 100644
--- a/user_guide/libraries/zip.html
+++ b/user_guide/libraries/zip.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/license.html b/user_guide/license.html
index 8c712e532..ddee1c085 100644
--- a/user_guide/license.html
+++ b/user_guide/license.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/overview/appflow.html b/user_guide/overview/appflow.html
index 9e070ac3d..2a3d52fe6 100644
--- a/user_guide/overview/appflow.html
+++ b/user_guide/overview/appflow.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/overview/at_a_glance.html b/user_guide/overview/at_a_glance.html
index 8614daed3..7fe915306 100644
--- a/user_guide/overview/at_a_glance.html
+++ b/user_guide/overview/at_a_glance.html
@@ -1 +1,172 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>CodeIgniter User Guide : CodeIgniter at a Glance</title> <style type='text/css' media='all'>@import url('../userguide.css');</style> <link rel='stylesheet' type='text/css' media='all' href='../userguide.css' /> <script type="text/javascript" src="../nav/nav.js"></script> <script type="text/javascript" src="../nav/prototype.lite.js"></script> <script type="text/javascript" src="../nav/moo.fx.js"></script> <script type="text/javascript" src="../nav/user_guide_menu.js"></script> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv='expires' content='-1' /> <meta http-equiv= 'pragma' content='no-cache' /> <meta name='robots' content='all' /> <meta name='author' content='Rick Ellis' /> <meta name='description' content='CodeIgniter User Guide' /> </head> <body> <!-- START NAVIGATION --> <div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div> <div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle.jpg" width="153" height="44" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div> <div id="masthead"> <table cellpadding="0" cellspacing="0" border="0" style="width:100%"> <tr> <td><h1>CodeIgniter User Guide Version 1.5.4</h1></td> <td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td> </tr> </table> </div> <!-- END NAVIGATION --> <!-- START BREADCRUMB --> <table cellpadding="0" cellspacing="0" border="0" style="width:100%"> <tr> <td id="breadcrumb"> <a href="http://www.codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp; <a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp; What is CodeIgniter? </td> <td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td> </tr> </table> <!-- END BREADCRUMB --> <br clear="all" /> <!-- START CONTENT --> <div id="content"> <h1>CodeIgniter at a Glance</h1> <h2>CodeIgniter is an Application Framework</h2> <p>CodeIgniter is a toolkit for people who build web application using PHP. Its goal is to enable you to develop projects much faster than you could if you were writing code from scratch, by providing a rich set of libraries for commonly needed tasks, as well as a simple interface and logical structure to access these libraries. CodeIgniter lets you creatively focus on your project by minimizing the amount of code needed for a given task.</p> <h2>CodeIgniter is Free</h2> <p>CodeIgniter is licensed under an Apache/BSD-style open source license so you can use it however you please. For more information please read the <a href="../license.html">license agreement</a>.</p> <h2>CodeIgniter Runs on PHP 4</h2> <p>CodeIgniter is written to be compatible with PHP 4. Although we would have loved to take advantage of the better object handling in PHP 5 since it would have simplified some things we had to find creative solutions for (looking your way, multiple inheritance), at the time of this writing PHP 5 is not in widespread use, which means we would be alienating most of our potential audience. Major OS vendors like RedHat have yet to support PHP 5, and they are unlikely to do so until 2007, so we felt that it did not serve the best interests of the PHP community to write CodeIgniter in PHP 5.</p> <p>Note: CodeIgniter will run on PHP 5. It simply does not take advantage of any native features that are only available in that version.</p> <h2>CodeIgniter is Light Weight</h2> <p>Truly light weight. The core system requires only a few very small libraries. This is in stark contrast to many frameworks that require significantly more resources. Additional libraries are loaded dynamically upon request, based on your needs for a given process, so the base system is very lean and quite fast. </p> <h2>CodeIgniter is Fast</h2> <p>Really fast. We challenge you to find a framework that has better performance than CodeIgniter.</p> <h2>CodeIgniter Uses M-V-C</h2> <p>CodeIgniter uses the Model-View-Controller approach, which allows great separation between logic and presentation. This is particularly good for projects in which designers are working with your template files, as the code these file contain will be minimized. We describe MVC in more detail on its own page.</p> <h2>CodeIgniter Generates Clean URLs</h2> <p>The URLs generated by CodeIgniter are clean and search-engine friendly. Rather than using the standard "query string" approach to URLs that is synonymous with dynamic systems, CodeIgniter uses a segment-based approach:</p> <code>www.your-site.com/<var>news</var>/<dfn>article</dfn>/<samp>345</samp></code> <p>Note: By default the index.php file is included in the URL but it can be removed using a simple .htaccess file.</p> <h2>CodeIgniter Packs a Punch</h2> <p>CodeIgniter comes with full-range of libraries that enable the most commonly needed web development tasks, like accessing a database, sending email, validating form data, maintaining sessions, manipulating images, working with XML-RPC data and much more.</p> <h2>CodeIgniter is Extensible</h2> <p>The system can be easily extended through the use of plugins and helper libraries, or through class extensions or system hooks.</p> <h2>CodeIgniter Does Not Require a Template Engine</h2> <p>Although CodeIgniter <em>does</em> come with a simple template parser that can be optionally used, it does not force you to use one. Template engines simply can not match the performance of native PHP, and the syntax that must be learned to use a template engine is usually only marginally easier than learning the basics of PHP. Consider this block of PHP code:</p> <code>&lt;ul><br /> <br /> &lt;?php foreach ($addressbook as $name):?><br /> <br /> &lt;li>&lt;?=$name?>&lt;/li><br /> <br /> &lt;?php endforeach; ?><br /> <br /> &lt;/ul></code> <p>Contrast this with the pseudo-code used by a template engine:</p> <code>&lt;ul><br /> <br /> {foreach from=$addressbook item="name"}<br /> <br /> &lt;li>{$name}&lt;/li><br /> <br /> {/foreach}<br /> <br /> &lt;/ul></code> <p>Yes, the template engine example is a bit cleaner, but it comes at the price of performance, as the pseudo-code must be converted back into PHP to run. Since one of our goals is <em>maximum performance</em>, we opted to not require the use of a template engine.</p> <h2>CodeIgniter is Thoroughly Documented</h2> <p>Programmers love to code and hate to write documentation. We're no different, of course, but since documentation is <strong>as important</strong> as the code itself, we are committed to doing it. Our source code is extremely clean and well commented as well.</p> <h2>CodeIgniter has a Friendly Community of Users</h2> <p>Our growing community of users can be seen actively participating in our <a href="http://www.codeigniter.com/forums/">Community Forums</a>.</p> </div> <!-- END CONTENT --> <div id="footer"> <p> Previous Topic:&nbsp;&nbsp;<a href="../installation/upgrading.html">Upgrading from an Older Version</a> &nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp; <a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp; <a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp; Next Topic:&nbsp;&nbsp;<a href="features.html">CodeIgniter Features</a> </p> <p><a href="http://www.codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2007 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">Ellislab, Inc.</a></p> </div> </body> </html> \ No newline at end of file
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html>
+<head>
+
+<title>CodeIgniter User Guide : CodeIgniter at a Glance</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='Rick Ellis' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle.jpg" width="153" height="44" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://www.codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+What is CodeIgniter?
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+<h1>CodeIgniter at a Glance</h1>
+
+
+<h2>CodeIgniter is an Application Framework</h2>
+
+<p>CodeIgniter is a toolkit for people who build web application using PHP. Its goal is to enable you to develop projects much faster than you could if you were writing code
+from scratch, by providing a rich set of libraries for commonly needed tasks, as well as a simple interface and
+logical structure to access these libraries. CodeIgniter lets you creatively focus on your project by
+minimizing the amount of code needed for a given task.</p>
+
+<h2>CodeIgniter is Free</h2>
+<p>CodeIgniter is licensed under an Apache/BSD-style open source license so you can use it however you please.
+For more information please read the <a href="../license.html">license agreement</a>.</p>
+
+
+<h2>CodeIgniter Runs on PHP 4</h2>
+<p>CodeIgniter is written to be compatible with PHP 4. Although we would have loved to take advantage of the better object handling
+in PHP 5 since it would have simplified some things we had to find creative solutions for (looking your way, multiple inheritance),
+at the time of this writing PHP 5 is not in widespread use, which means we would be alienating most of our
+potential audience. Major OS vendors like RedHat have yet to support PHP 5, and they are unlikely to do so until 2007, so
+we felt that it did not serve the best interests of the PHP community to write CodeIgniter in PHP 5.</p>
+
+<p>Note: CodeIgniter will run on PHP 5. It simply does not take advantage of any native features that are only available in that version.</p>
+
+<h2>CodeIgniter is Light Weight</h2>
+<p>Truly light weight. The core system requires only a few very small libraries. This is in stark contrast to many frameworks that require significantly more resources.
+Additional libraries are loaded dynamically upon request, based on your needs for a given process, so the base system
+is very lean and quite fast.
+</p>
+
+<h2>CodeIgniter is Fast</h2>
+<p>Really fast. We challenge you to find a framework that has better performance than CodeIgniter.</p>
+
+
+<h2>CodeIgniter Uses M-V-C</h2>
+<p>CodeIgniter uses the Model-View-Controller approach, which allows great separation between logic and presentation.
+This is particularly good for projects in which designers are working with your template files, as the code these file contain will be minimized. We describe MVC in more detail on its own page.</p>
+
+<h2>CodeIgniter Generates Clean URLs</h2>
+<p>The URLs generated by CodeIgniter are clean and search-engine friendly. Rather than using the standard "query string"
+approach to URLs that is synonymous with dynamic systems, CodeIgniter uses a segment-based approach:</p>
+
+<code>www.your-site.com/<var>news</var>/<dfn>article</dfn>/<samp>345</samp></code>
+
+<p>Note: By default the index.php file is included in the URL but it can be removed using a simple .htaccess file.</p>
+
+<h2>CodeIgniter Packs a Punch</h2>
+<p>CodeIgniter comes with full-range of libraries that enable the most commonly needed web development tasks,
+like accessing a database, sending email, validating form data, maintaining sessions, manipulating images, working with XML-RPC data and
+much more.</p>
+
+<h2>CodeIgniter is Extensible</h2>
+<p>The system can be easily extended through the use of plugins and helper libraries, or through class extensions or system hooks.</p>
+
+
+<h2>CodeIgniter Does Not Require a Template Engine</h2>
+<p>Although CodeIgniter <em>does</em> come with a simple template parser that can be optionally used, it does not force you to use one.
+
+Template engines simply can not match the performance of native PHP, and the syntax that must be learned to use a template
+engine is usually only marginally easier than learning the basics of PHP. Consider this block of PHP code:</p>
+
+<code>&lt;ul><br />
+<br />
+&lt;?php foreach ($addressbook as $name):?><br />
+<br />
+&lt;li>&lt;?=$name?>&lt;/li><br />
+<br />
+&lt;?php endforeach; ?><br />
+<br />
+&lt;/ul></code>
+
+<p>Contrast this with the pseudo-code used by a template engine:</p>
+
+<code>&lt;ul><br />
+<br />
+{foreach from=$addressbook item="name"}<br />
+<br />
+&lt;li>{$name}&lt;/li><br />
+<br />
+{/foreach}<br />
+<br />
+&lt;/ul></code>
+
+<p>Yes, the template engine example is a bit cleaner, but it comes at the price of performance, as the pseudo-code must be converted
+back into PHP to run. Since one of our goals is <em>maximum performance</em>, we opted to not require the use of a template engine.</p>
+
+
+<h2>CodeIgniter is Thoroughly Documented</h2>
+<p>Programmers love to code and hate to write documentation. We're no different, of course, but
+since documentation is <strong>as important</strong> as the code itself,
+we are committed to doing it. Our source code is extremely clean and well commented as well.</p>
+
+
+<h2>CodeIgniter has a Friendly Community of Users</h2>
+
+<p>Our growing community of users can be seen actively participating in our <a href="http://www.codeigniter.com/forums/">Community Forums</a>.</p>
+
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="../installation/upgrading.html">Upgrading from an Older Version</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="features.html">CodeIgniter Features</a>
+</p>
+<p><a href="http://www.codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2007 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">Ellislab, Inc.</a></p>
+</div>
+
+</body>
+</html> \ No newline at end of file
diff --git a/user_guide/overview/features.html b/user_guide/overview/features.html
index 02b953ed4..14bace865 100644
--- a/user_guide/overview/features.html
+++ b/user_guide/overview/features.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/overview/goals.html b/user_guide/overview/goals.html
index 4685da8eb..738c91dac 100644
--- a/user_guide/overview/goals.html
+++ b/user_guide/overview/goals.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/overview/index.html b/user_guide/overview/index.html
index 9b6abac26..66622b44e 100644
--- a/user_guide/overview/index.html
+++ b/user_guide/overview/index.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/overview/mvc.html b/user_guide/overview/mvc.html
index b168542f6..868c9612c 100644
--- a/user_guide/overview/mvc.html
+++ b/user_guide/overview/mvc.html
@@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
diff --git a/user_guide/toc.html b/user_guide/toc.html
index 3f6b16e43..6ab19a3c9 100644
--- a/user_guide/toc.html
+++ b/user_guide/toc.html
@@ -29,7 +29,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
-<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
+<td><h1>CodeIgniter User Guide Version 1.6.0</h1></td>
</tr>
</table>
</div>