summaryrefslogtreecommitdiffstats
path: root/user_guide_src
diff options
context:
space:
mode:
Diffstat (limited to 'user_guide_src')
-rw-r--r--user_guide_src/source/changelog.rst6
-rw-r--r--user_guide_src/source/database/active_record.rst109
-rw-r--r--user_guide_src/source/helpers/directory_helper.rst27
-rw-r--r--user_guide_src/source/installation/upgrade_200.rst52
4 files changed, 180 insertions, 14 deletions
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index 3e1643524..8b74fa94c 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -9,6 +9,7 @@ Release Date: Not Released
- General Changes
+ - Added an optional backtrace to php-error template.
- Added Android to the list of user agents.
- Added Windows 7 to the list of user platforms.
- Callback validation rules can now accept parameters like any other
@@ -46,6 +47,9 @@ Release Date: Not Released
$this->db->like() in the :doc:`Database
Driver <database/active_record>`.
- Added $this->db->insert_batch() support to the OCI8 (Oracle) driver.
+ - Added new :doc:`Active Record <database/active_record>` methods that return
+ the SQL string of queries without executing them: get_compiled_select(),
+ get_compiled_insert(), get_compiled_update(), get_compiled_delete().
- Libraries
@@ -320,6 +324,8 @@ Bug fixes for 2.0.1
- Fixed a bug (Reactor #69) where the SHA1 library was named
incorrectly.
+.. _2.0.0-changelog:
+
Version 2.0.0
=============
diff --git a/user_guide_src/source/database/active_record.rst b/user_guide_src/source/database/active_record.rst
index e1fc00bc5..5555a30bc 100644
--- a/user_guide_src/source/database/active_record.rst
+++ b/user_guide_src/source/database/active_record.rst
@@ -54,6 +54,37 @@ $query, which can be used to show the results::
Please visit the :doc:`result functions <results>` page for a full
discussion regarding result generation.
+$this->db->get_compiled_select()
+================================
+
+Compiles the selection query just like `$this->db->get()`_ but does not *run*
+the query. This method simply returns the SQL query as a string.
+
+Example::
+
+ $sql = $this->db->get_compiled_select('mytable');
+ echo $sql;
+
+ // Produces string: SELECT * FROM mytable
+
+The second parameter enables you to set whether or not the active record query
+will be reset (by default it will be&mdash;just like `$this->db->get()`)::
+
+ echo $this->db->limit(10,20)->get_compiled_select('mytable', FALSE);
+ // Produces string: SELECT * FROM mytable LIMIT 20, 10
+ // (in MySQL. Other databases have slightly different syntax)
+
+ echo $this->db->select('title, content, date')->get_compiled_select();
+
+ // Produces string: SELECT title, content, date FROM mytable
+
+The key thing to notice in the above example is that the second query did not
+utilize `$this->db->from()`_ and did not pass a table name into the first
+parameter. The reason for this outcome is because the query has not been
+executed using `$this->db->get()`_ which resets values or reset directly
+using `$this-db->reset_query()`_.
+
+
$this->db->get_where()
======================
@@ -540,6 +571,41 @@ object.
.. note:: All values are escaped automatically producing safer queries.
+$this->db->get_compiled_insert()
+================================
+Compiles the insertion query just like `$this->db->insert()`_ but does not
+*run* the query. This method simply returns the SQL query as a string.
+
+Example::
+
+ $data = array(
+ 'title' => 'My title',
+ 'name' => 'My Name',
+ 'date' => 'My date'
+ );
+
+ $sql = $this->db->set($data)->get_compiled_insert('mytable');
+ echo $sql;
+
+ // Produces string: INSERT INTO mytable (title, name, date) VALUES ('My title', 'My name', 'My date')
+
+The second parameter enables you to set whether or not the active record query
+will be reset (by default it will be--just like `$this->db->insert()`_)::
+
+ echo $this->db->set('title', 'My Title')->get_compiled_insert('mytable', FALSE);
+
+ // Produces string: INSERT INTO mytable (title) VALUES ('My Title')
+
+ echo $this->db->set('content', 'My Content')->get_compiled_insert();
+
+ // Produces string: INSERT INTO mytable (title, content) VALUES ('My Title', 'My Content')
+
+The key thing to notice in the above example is that the second query did not
+utlize `$this->db->from()`_ nor did it pass a table name into the first
+parameter. The reason this worked is because the query has not been executed
+using `$this->db->insert()`_ which resets values or reset directly using
+`$this->db->reset_query()`_.
+
$this->db->insert_batch()
=========================
@@ -717,6 +783,14 @@ array of values, the third parameter is the where key.
.. note:: All values are escaped automatically producing safer queries.
+$this->db->get_compiled_update()
+================================
+
+This works exactly the same way as ``$this->db->get_compiled_insert()`` except
+that it produces an UPDATE SQL string instead of an INSERT SQL string.
+
+For more information view documentation for `$this->get_compiled_insert()`_.
+
*************
Deleting Data
@@ -784,6 +858,13 @@ Generates a truncate SQL string and runs the query.
.. note:: If the TRUNCATE command isn't available, truncate() will
execute as "DELETE FROM table".
+
+$this->db->get_compiled_delete()
+================================
+This works exactly the same way as ``$this->db->get_compiled_insert()`` except
+that it produces a DELETE SQL string instead of an INSERT SQL string.
+
+For more information view documentation for `$this->get_compiled_insert()`_.
***************
Method Chaining
@@ -854,3 +935,31 @@ Here's a usage example::
where, like, group_by, having, order_by, set
+
+*******************
+Reset Active Record
+*******************
+
+Resetting Active Record allows you to start fresh with your query without
+executing it first using a method like $this->db->get() or $this->db->insert().
+Just like the methods that execute a query, this will *not* reset items you've
+cached using `Active Record Caching`_.
+
+This is useful in situations where you are using Active Record to generate SQL
+(ex. ``$this->db->get_compiled_select()``) but then choose to, for instance,
+run the query::
+
+ // Note that the second parameter of the get_compiled_select method is FALSE
+ $sql = $this->db->select(array('field1','field2'))
+ ->where('field3',5)
+ ->get_compiled_select('mytable', FALSE);
+
+ // ...
+ // Do something crazy with the SQL code... like add it to a cron script for
+ // later execution or something...
+ // ...
+
+ $data = $this->db->get()->result_array();
+
+ // Would execute and return an array of results of the following query:
+ // SELECT field1, field1 from mytable where field3 = 5;
diff --git a/user_guide_src/source/helpers/directory_helper.rst b/user_guide_src/source/helpers/directory_helper.rst
index 6c259adb1..fd169886c 100644
--- a/user_guide_src/source/helpers/directory_helper.rst
+++ b/user_guide_src/source/helpers/directory_helper.rst
@@ -18,15 +18,20 @@ This helper is loaded using the following code
The following functions are available:
-directory_map('source directory')
-=================================
+directory_map()
+===============
This function reads the directory path specified in the first parameter
and builds an array representation of it and all its contained files.
+
+.. php:method:: directory_map($source_dir[, $directory_depth = 0[, $hidden = FALSE]])
-Example
-
-::
+ :param string $source_dir: path to the ource directory
+ :param integer $directory_depth: depth of directories to traverse (0 =
+ fully recursive, 1 = current dir, etc)
+ :param boolean $hidden: whether to include hidden directories
+
+Examples::
$map = directory_map('./mydirectory/');
@@ -35,23 +40,17 @@ Example
Sub-folders contained within the directory will be mapped as well. If
you wish to control the recursion depth, you can do so using the second
-parameter (integer). A depth of 1 will only map the top level directory
-
-::
+parameter (integer). A depth of 1 will only map the top level directory::
$map = directory_map('./mydirectory/', 1);
By default, hidden files will not be included in the returned array. To
-override this behavior, you may set a third parameter to true (boolean)
-
-::
+override this behavior, you may set a third parameter to true (boolean)::
$map = directory_map('./mydirectory/', FALSE, TRUE);
Each folder name will be an array index, while its contained files will
-be numerically indexed. Here is an example of a typical array
-
-::
+be numerically indexed. Here is an example of a typical array::
Array (    
[libraries] => Array    
diff --git a/user_guide_src/source/installation/upgrade_200.rst b/user_guide_src/source/installation/upgrade_200.rst
index 064e1b534..0bcbd5c99 100644
--- a/user_guide_src/source/installation/upgrade_200.rst
+++ b/user_guide_src/source/installation/upgrade_200.rst
@@ -5,6 +5,10 @@ Upgrading from 1.7.2 to 2.0.0
Before performing an update you should take your site offline by
replacing the index.php file with a static one.
+*******************
+Update Instructions
+*******************
+
Step 1: Update your CodeIgniter files
=====================================
@@ -88,3 +92,51 @@ Step 8: Update your user guide
Please replace your local copy of the user guide with the new version,
including the image files.
+
+
+************
+Update Notes
+************
+
+Please refer to the :ref:`2.0.0 Change Log <2.0.0-changelog>` for full
+details, but here are some of the larger changes that are more likely to
+impact your code:
+
+- CodeIgniter now requires PHP 5.1.6.
+- Scaffolding has been removed.
+- The CAPTCHA plugin in now a :doc:`helper </helpers/captcha_helper>`.
+- The JavaScript calendar plugin was removed.
+- The *system/cache* and *system/logs* directories are now in the application
+ directory.
+- The Validation class has been removed. Please see the
+ :doc:`Form Validation library </libraries/form_validation>`
+- "default" is now a reserved name.
+- The xss_clean() function has moved to the :doc:`Security Class
+ </libraries/security>`.
+- do_xss_clean() now returns FALSE if the uploaded file fails XSS checks.
+- The :doc:`Session Class </libraries/sessions>` requires now the use of an
+ encryption key set in the config file.
+- The following deprecated Active Record functions have been removed:
+ ``orwhere``, ``orlike``, ``groupby``, ``orhaving``, ``orderby``,
+ ``getwhere``.
+- ``_drop_database()`` and ``_create_database()`` functions have been removed
+ from the db utility drivers.
+- The ``dohash()`` function of the :doc:`Security helper
+ </helpers/security_helper>`
+ has been renamed to ``do_hash()`` for naming consistency.
+
+The config folder
+=================
+
+The following files have been changed:
+
+- config.php
+- database.php
+- mimes.php
+- routes.php
+- user_agents.php
+
+The following files have been added:
+
+- foreign_chars.php
+- profiler.php