diff options
author | Jamie Rumbelow <jamie@jamierumbelow.net> | 2012-03-06 22:27:46 +0100 |
---|---|---|
committer | Jamie Rumbelow <jamie@jamierumbelow.net> | 2012-03-06 22:27:46 +0100 |
commit | 3b1355c595127280d6d84d8b617a91fbeda319f5 (patch) | |
tree | 61e9d7c334e350846ffc3b528fbcbe85b036e1e9 /user_guide_src/source/database | |
parent | 576b47e9947d4f5bc25a3f72e3978a3d7f9ca1de (diff) | |
parent | 738f53448fecd1a27c7f89965fbfc47b3bafdb9b (diff) |
Merge branch 'develop' of git://github.com/EllisLab/CodeIgniter into develop
Conflicts:
system/database/DB_driver.php
system/database/DB_query_builder.php
Diffstat (limited to 'user_guide_src/source/database')
-rw-r--r-- | user_guide_src/source/database/helpers.rst | 6 | ||||
-rw-r--r-- | user_guide_src/source/database/queries.rst | 17 | ||||
-rw-r--r-- | user_guide_src/source/database/results.rst | 9 | ||||
-rw-r--r-- | user_guide_src/source/database/utilities.rst | 6 |
4 files changed, 32 insertions, 6 deletions
diff --git a/user_guide_src/source/database/helpers.rst b/user_guide_src/source/database/helpers.rst index 7ea19e9f6..e8a5ac801 100644 --- a/user_guide_src/source/database/helpers.rst +++ b/user_guide_src/source/database/helpers.rst @@ -7,9 +7,9 @@ $this->db->insert_id() The insert ID number when performing database inserts. -.. note:: If using the PDO driver with PostgreSQL, this function requires - a $name parameter, which specifies the appropriate sequence to check - for the insert id. +.. note:: If using the PDO driver with PostgreSQL, or using the Interbase + driver, this function requires a $name parameter, which specifies the + appropriate sequence to check for the insert id. $this->db->affected_rows() =========================== diff --git a/user_guide_src/source/database/queries.rst b/user_guide_src/source/database/queries.rst index 2ba3d3f4a..d23efecb3 100644 --- a/user_guide_src/source/database/queries.rst +++ b/user_guide_src/source/database/queries.rst @@ -112,3 +112,20 @@ The secondary benefit of using binds is that the values are automatically escaped, producing safer queries. You don't have to remember to manually escape data; the engine does it automatically for you. + +*************** +Handling Errors +*************** + +$this->db->error(); +=================== + +If you need to get the last error that has occured, the error() method +will return an array containing its code and message. Here's a quick +example:: + + if ( ! $this->db->simple_query('SELECT `example_field` FROM `example_table`')) + { + $error = $this->db->error(); // Has keys 'code' and 'message' + } + diff --git a/user_guide_src/source/database/results.rst b/user_guide_src/source/database/results.rst index 4f93c794d..865345762 100644 --- a/user_guide_src/source/database/results.rst +++ b/user_guide_src/source/database/results.rst @@ -150,6 +150,12 @@ is the variable that the query result object is assigned to:: echo $query->num_rows(); +.. note:: + Not all database drivers have a native way of getting the total + number of rows for a result set. When this is the case, all of + the data is prefetched and count() is manually called on the + resulting array in order to achieve the same functionality. + $query->num_fields() ===================== @@ -182,5 +188,4 @@ Example:: $row = $query2->row(); echo $row->name; - $query2->free_result();// The $query2 result object will no longer be available - + $query2->free_result(); // The $query2 result object will no longer be available diff --git a/user_guide_src/source/database/utilities.rst b/user_guide_src/source/database/utilities.rst index b0920109f..3805ffb87 100644 --- a/user_guide_src/source/database/utilities.rst +++ b/user_guide_src/source/database/utilities.rst @@ -161,7 +161,11 @@ $this->dbutil->backup() Permits you to backup your full database or individual tables. The backup data can be compressed in either Zip or Gzip format. -.. note:: This features is only available for MySQL databases. +.. note:: This features is only available for MySQL and Interbase/Firebird databases. + +.. note:: For Interbase/Firebird databases, the backup file name is the only parameter. + + Eg. $this->dbutil->backup('db_backup_filename'); .. note:: Due to the limited execution time and memory available to PHP, backing up very large databases may not be possible. If your database is |