summaryrefslogtreecommitdiffstats
path: root/user_guide_src/source
diff options
context:
space:
mode:
authorJonatas Miguel <jonatas.df.miguel@gmail.com>2012-10-31 15:44:02 +0100
committerJonatas Miguel <jonatas.df.miguel@gmail.com>2012-10-31 15:44:02 +0100
commit3ccc386be4e0e1e4b3d47f1785e11d4b8613ef72 (patch)
treef1c8cd29775537b8da76143edeec5b6c8d659550 /user_guide_src/source
parenta9a1d2520493211ca35f7ab56866d0e154afc1c3 (diff)
parentf2b19fee7876708c7a7bb5cba6b7df682a9d2a53 (diff)
Merge branch 'develop' of git://github.com/EllisLab/CodeIgniter into develop
Diffstat (limited to 'user_guide_src/source')
-rw-r--r--user_guide_src/source/changelog.rst53
-rw-r--r--user_guide_src/source/database/configuration.rst1
-rw-r--r--user_guide_src/source/database/query_builder.rst4
-rw-r--r--user_guide_src/source/general/routing.rst30
-rw-r--r--user_guide_src/source/helpers/form_helper.rst47
-rw-r--r--user_guide_src/source/helpers/string_helper.rst3
-rw-r--r--user_guide_src/source/installation/upgrade_300.rst89
-rw-r--r--user_guide_src/source/libraries/caching.rst57
-rw-r--r--user_guide_src/source/libraries/cart.rst14
-rw-r--r--user_guide_src/source/libraries/form_validation.rst190
10 files changed, 313 insertions, 175 deletions
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index 990ba1386..2df8ca7c1 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -75,7 +75,9 @@ Release Date: Not Released
- Refactored ``plural()`` and ``singular()`` to avoid double pluralization and support more words.
- Added an optional third parameter to ``force_download()`` that enables/disables sending the actual file MIME type in the Content-Type header (disabled by default).
- Added a work-around in ``force_download()`` for a bug Android <= 2.1, where the filename extension needs to be in uppercase.
- - ``form_dropdown()`` will now also take an array for unity with other form helpers.
+ - :doc:`Form Helper <helpers/form_helper>` changes include:
+ - ``form_dropdown()`` will now also take an array for unity with other form helpers.
+ - ``form_prep()`` is now **DEPRECATED** and only acts as an alias for :doc:`common function <general/common_functions>` ``html_escape()``.
- ``do_hash()`` now uses PHP's native ``hash()`` function (supporting more algorithms) and is deprecated.
- Removed previously deprecated helper function ``js_insert_smiley()`` from :doc:`Smiley Helper <helpers/smiley_helper>`.
- :doc:`File Helper <helpers/file_helper>` changes include:
@@ -83,6 +85,7 @@ Release Date: Not Released
- Added an optional paramater to ``delete_files()`` to enable it to skip deleting files such as .htaccess and index.html.
- ``read_file()`` is now a deprecated alias of ``file_get_contents()``.
- :doc:`Security Helper <helpers/security_helper>` function ``strip_image_tags()`` is now an alias for the same method in the :doc:`Security Library <libraries/security>`.
+ - Deprecated :doc:`String Helper <helpers/string_helper>` function ``repeater()`` - it's just an alias for PHP's native ``str_repeat()``.
- Database
@@ -101,7 +104,8 @@ Release Date: Not Released
- Server version checking is now done via ``mysqli::$server_info`` instead of running an SQL query.
- Added persistent connections support for PHP >= 5.3.
- Added support for ``backup()`` in :doc:`Database Utilities <database/utilities>`.
- - Added *dsn* configuration setting for drivers that support DSN strings (PDO, PostgreSQL, Oracle, ODBC, CUBRID).
+ - Added **dsn** configuration setting for drivers that support DSN strings (PDO, PostgreSQL, Oracle, ODBC, CUBRID).
+ - Added **schema** configuration setting (defaults to *public*) for drivers that might need it (currently used by PostgreSQL and ODBC).
- Improved PDO database support.
- Added Interbase/Firebird database support via the *ibase* driver.
- Added an optional database name parameter to ``db_select()``.
@@ -173,9 +177,10 @@ Release Date: Not Released
- Added *max_filename_increment* config setting.
- Added an "index" parameter to the ``data()`` method.
- :doc:`Cart library <libraries/cart>` changes include:
- - It now auto-increments quantity's instead of just resetting it, this is the default behaviour of large e-commerce sites.
- - Product Name strictness can be disabled via the Cart Library by switching "$product_name_safe".
- - Added function remove() to remove a cart item, updating with quantity of 0 seemed like a hack but has remained to retain compatibility.
+ - ``insert()`` now auto-increments quantity for an item when inserted twice instead of resetting it, this is the default behaviour of large e-commerce sites.
+ - *Product Name* strictness can be disabled by switching the ``$product_name_safe`` property to FALSE.
+ - Added method ``remove()`` to remove a cart item, updating with quantity of 0 seemed like a hack but has remained to retain compatibility.
+ - Added method ``get_item()`` to enable retrieving data for a single cart item.
- :doc:`Image Manipulation library <libraries/image_lib>` changes include:
- The initialize() method now only sets existing class properties.
- Added support for 3-length hex color values for *wm_font_color* and *wm_shadow_color* properties, as well as validation for them.
@@ -195,8 +200,10 @@ Release Date: Not Released
- Fields that have empty rules set no longer run through validation (and therefore are not considered erroneous).
- Added rule *differs* to check if the value of a field differs from the value of another field.
- Added support for setting :doc:`Table <libraries/table>` class defaults in a config file.
- - Added a Wincache driver to the :doc:`Caching Library <libraries/caching>`.
- - Added a Redis driver to the :doc:`Caching Library <libraries/caching>`.
+ - :doc:`Caching Library <libraries/caching>` changes include:
+ - Added Wincache driver.
+ - Added Redis driver.
+ - Added a *key_prefix* option for cache IDs.
- :doc:`Email library <libraries/email>` changes include:
- Added custom filename to ``Email::attach()`` as ``$this->email->attach($filename, $disposition, $newname)``.
- Added possibility to send attachment as buffer string in ``Email::attach()`` as ``$this->email->attach($buffer, $disposition, $newname, $mime)``.
@@ -223,18 +230,26 @@ Release Date: Not Released
- Core
- - Changed private methods in the :doc:`URI Library <libraries/uri>` to protected so MY_URI can override them.
+ - :doc:`URI Library <libraries/uri>` changes include:
+ - Changed private methods to protected so that MY_URI can override them.
+ - Renamed internal method ``_parse_cli_args()`` to ``_parse_argv()``.
+ - Renamed internal method ``_detect_uri()`` to ``_parse_request_uri()``.
+ - Changed ``_parse_request_uri()`` to accept absolute URIs for compatibility with HTTP/1.1 as per `RFC2616 <http://www.ietf.org/rfc/rfc2616.txt>`.
+ - Added protected method ``_parse_query_string()`` to URI paths in the the **QUERY_STRING** value, like ``_parse_request_uri()`` does.
- Removed ``CI_CORE`` boolean constant from *CodeIgniter.php* (no longer Reactor and Core versions).
- :doc:`Loader Library <libraries/loader>` changes include:
- Added method ``get_vars()`` to the Loader to retrieve all variables loaded with ``$this->load->vars()``.
- - ``CI_Loader::_ci_autoloader()`` is now a protected method.
+ - ``_ci_autoloader()`` is now a protected method.
- Added autoloading of drivers with ``$autoload['drivers']``.
- - ``CI_Loader::library()`` will now load drivers as well, for backward compatibility of converted libraries (like Session).
- - ``$config['rewrite_short_tags']`` now has no effect when using PHP 5.4 as *<?=* will always be available.
+ - ``library()`` method will now load drivers as well, for backward compatibility of converted libraries (like :doc:`Session <libraries/sessions>`).
+ - ``$config['rewrite_short_tags']`` now has no effect when using PHP 5.4 as ``<?=`` will always be available.
+ - Changed method ``config()`` to return whatever ``CI_Config::load()`` returns instead of always being void.
- :doc:`Input Library <libraries/input>` changes include:
- Added ``method()`` to retrieve ``$_SERVER['REQUEST_METHOD']``.
- - Modified ``valid_ip()`` to use PHP's ``filter_var()``.
- Added support for arrays and network addresses (e.g. 192.168.1.1/24) for use with the *proxy_ips* setting.
+ - Changed method ``valid_ip()`` to use PHP's native ``filter_var()`` function.
+ - Changed internal method ``_sanitize_globals()`` to skip enforcing reversal of *register_globals* in PHP 5.4+, where this functionality no longer exists.
+ - Changed methods ``get()``, ``post()``, ``get_post()``, ``cookie()``, ``server()``, ``user_agent()`` to return NULL instead of FALSE when no value is found.
- :doc:`Common functions <general/common_functions>` changes include:
- Added function ``get_mimes()`` to return the *config/mimes.php* array.
- Added support for HTTP code 303 ("See Other") in ``set_status_header()``.
@@ -247,7 +262,9 @@ Release Date: Not Released
- Added method ``get_content_type()``.
- Added a second argument to method ``set_content_type()`` that allows setting the document charset as well.
- ``$config['time_reference']`` now supports all timezone strings supported by PHP.
- - Changed :doc:`Config Library <libraries/config>` method ``site_url()`` to accept an array as well.
+ - :doc:`Config Library <libraries/config>` changes include:
+ - Changed ``site_url()`` method to accept an array as well.
+ - Removed internal method ``_assign_to_config()`` and moved it's implementation in *CodeIgniter.php* instead.
- :doc:`Security Library <libraries/security>` changes include:
- Added method ``strip_image_tags()``.
- Added ``$config['csrf_regeneration']``, which makes token regeneration optional.
@@ -382,6 +399,14 @@ Bug fixes for 3.0
- Fixed a bug (#1255) - :doc:`User Agent Library <libraries/user_agent>` method ``is_referral()`` only checked if ``$_SERVER['HTTP_REFERER']`` exists.
- Fixed a bug (#1146) - :doc:`Download Helper <helpers/download_helper>` function ``force_download()`` incorrectly sent *Cache-Control* directives *pre-check* and *post-check* to Internet Explorer.
- Fixed a bug (#1811) - :doc:`URI Library <libraries/uri>` didn't properly cache segments for ``uri_to_assoc()`` and ``ruri_to_assoc()``.
+- Fixed a bug (#1506) - :doc:`Form Helpers <helpers/form_helper>` set empty *name* attributes.
+- Fixed a bug (#59) - :doc:`Query Builder <database/query_builder>` method ``count_all_results()`` ignored the DISTINCT clause.
+- Fixed a bug (#1624) - :doc:`Form Validation Library <libraries/form_validation>` rule **matches** didn't property handle array field names.
+- Fixed a bug (#1630) - :doc:`Form Helper <helpers/form_helper>` function ``set_value()`` didn't escape HTML entities.
+- Fixed a bug (#142) - :doc:`Form Helper <helpers/form_helper>` function ``form_dropdown()`` didn't escape HTML entities in option values.
+- Fixed a bug (#50) - :doc:`Session Library <libraries/sessions>` unnecessarily stripped slashed from serialized data, making it impossible to read objects in a namespace.
+- Fixed a bug (#658) - :doc:`Routing <general/routing>` wildcard **:any** didn't work as advertised and matched multiple URI segments instead of all characters within a single segment.
+- Fixed a bug (#1938) - :doc:`Email <libraries/email>` where the email library removed multiple spaces inside a pre-formatted plain text message.
Version 2.1.3
=============
@@ -396,7 +421,7 @@ Bug fixes for 2.1.3
- Fixed a bug (#1543) - File-based :doc:`Caching <libraries/caching>` method ``get_metadata()`` used a non-existent array key to look for the TTL value.
- Fixed a bug (#1314) - :doc:`Session Library <libraries/sessions>` method ``sess_destroy()`` didn't destroy the userdata array.
-- Fixed a bug (#804) - Profiler library was trying to handle objects as strings in some cases, resulting in *E_WARNING* messages being issued by ``htmlspecialchars()``.
+- Fixed a bug (#804) - :doc:`Profiler library <general/profiling>` was trying to handle objects as strings in some cases, resulting in *E_WARNING* messages being issued by ``htmlspecialchars()``.
- Fixed a bug (#1699) - :doc:`Migration Library <libraries/migration>` ignored the ``$config['migration_path']`` setting.
- Fixed a bug (#227) - :doc:`Input Library <libraries/input>` allowed unconditional spoofing of HTTP clients' IP addresses through the *HTTP_CLIENT_IP* header.
- Fixed a bug (#907) - :doc:`Input Library <libraries/input>` ignored *HTTP_X_CLUSTER_CLIENT_IP* and *HTTP_X_CLIENT_IP* headers when checking for proxies.
diff --git a/user_guide_src/source/database/configuration.rst b/user_guide_src/source/database/configuration.rst
index 668496324..34cefffbd 100644
--- a/user_guide_src/source/database/configuration.rst
+++ b/user_guide_src/source/database/configuration.rst
@@ -182,6 +182,7 @@ Explanation of Values:
customizable by the end user.
**autoinit** Whether or not to automatically connect to the database when the library loads. If set to false,
the connection will take place prior to executing the first query.
+**schema** The database schema, defaults to 'public'. Used by PostgreSQL and ODBC drivers.
**encrypt** Whether or not to use an encrypted connection.
**compress** Whether or not to use client compression (MySQL only).
**stricton** TRUE/FALSE (boolean) - Whether to force "Strict Mode" connections, good for ensuring strict SQL
diff --git a/user_guide_src/source/database/query_builder.rst b/user_guide_src/source/database/query_builder.rst
index 5380d0998..61cd7dfed 100644
--- a/user_guide_src/source/database/query_builder.rst
+++ b/user_guide_src/source/database/query_builder.rst
@@ -492,8 +492,8 @@ Or multiple function calls can be made if you need multiple fields.
.. note:: order_by() was formerly known as orderby(), which has been
removed.
-.. note:: random ordering is not currently supported in Oracle or MSSQL
- drivers. These will default to 'ASC'.
+.. note:: Random ordering is not currently supported in Oracle and
+ will default to ASC instead.
$this->db->limit()
==================
diff --git a/user_guide_src/source/general/routing.rst b/user_guide_src/source/general/routing.rst
index 144f129e8..43c181669 100644
--- a/user_guide_src/source/general/routing.rst
+++ b/user_guide_src/source/general/routing.rst
@@ -29,7 +29,7 @@ Setting your own routing rules
Routing rules are defined in your application/config/routes.php file. In
it you'll see an array called $route that permits you to specify your
own routing criteria. Routes can either be specified using wildcards or
-Regular Expressions
+Regular Expressions.
Wildcards
=========
@@ -47,7 +47,11 @@ segment of the URL, and a number is found in the second segment, the
You can match literal values or you can use two wildcard types:
**(:num)** will match a segment containing only numbers.
-**(:any)** will match a segment containing any character.
+**(:any)** will match a segment containing any character (except for '/', which is the segment delimiter).
+
+.. note:: Wildcards are actually aliases for regular expressions, with
+ **:any** being translated to **[^/]+** and **:num** to **[0-9]+**,
+ respectively.
.. note:: Routes will run in the order they are defined. Higher routes
will always take precedence over lower ones.
@@ -104,12 +108,28 @@ rules. Any valid regular expression is allowed, as are back-references.
A typical RegEx route might look something like this::
- $route['products/([a-z]+)/(\d+)'] = "$1/id_$2";
+ $route['products/([a-z]+)/(\d+)'] = '$1/id_$2';
In the above example, a URI similar to products/shirts/123 would instead
-call the shirts controller class and the id_123 function.
+call the shirts controller class and the id_123 method.
+
+With regular expressions, you can also catch a segment containing a
+forward slash ('/'), which would usually represent the delimiter between
+multiple segments.
+For example, if a user accesses a password protected area of your web
+application and you wish to be able to redirect them back to the same
+page after they log in, you may find this example useful::
+
+ $route['login/(.+)'] = 'auth/login/$1';
+
+That will call the auth controller class and its ``login()`` method,
+passing everything contained in the URI after *login/* as a parameter.
+
+For those of you who don't know regular expressions and want to learn
+more about them, `regular-expressions.info <http://www.regular-expressions.info/>`
+might be a good starting point.
-You can also mix and match wildcards with regular expressions.
+..note:: You can also mix and match wildcards with regular expressions.
Callbacks
=========
diff --git a/user_guide_src/source/helpers/form_helper.rst b/user_guide_src/source/helpers/form_helper.rst
index fa7b3dbf9..015bf1162 100644
--- a/user_guide_src/source/helpers/form_helper.rst
+++ b/user_guide_src/source/helpers/form_helper.rst
@@ -463,29 +463,6 @@ the tag. For example
echo form_close($string);
// Would produce: </form> </div></div>
-form_prep()
-===========
-
-Allows you to safely use HTML and characters such as quotes within form
-elements without breaking out of the form. Consider this example
-
-::
-
- $string = 'Here is a string containing "quoted" text.';
- <input type="text" name="myform" value="$string" />
-
-Since the above string contains a set of quotes it will cause the form
-to break. The `form_prep()` function converts HTML so that it can be used
-safely
-
-::
-
- <input type="text" name="myform" value="<?php echo form_prep($string); ?>" />
-
-.. note:: If you use any of the form helper functions listed in this page the form
- values will be prepped automatically, so there is no need to call this
- function. Use it only if you are creating your own form elements.
-
set_value()
===========
@@ -546,4 +523,26 @@ This function is identical to the **set_checkbox()** function above.
.. note:: If you are using the Form Validation class, you must always specify a rule for your field,
even if empty, in order for the set_*() functions to work. This is because if a Form Validation object
is defined, the control for set_*() is handed over to a method of the class instead of the generic helper
- function. \ No newline at end of file
+ function.
+
+Escaping field values
+=====================
+
+You may need to use HTML and characters such as quotes within form
+elements. In order to do that safely, you'll need to use
+:doc:`common function <../general/common_functions>` ``html_escape()``.
+
+Consider the following example::
+
+ $string = 'Here is a string containing "quoted" text.';
+ <input type="text" name="myform" value="$string" />
+
+Since the above string contains a set of quotes it will cause the form
+to break. The ``html_escape()`` function converts HTML so that it can be
+used safely::
+
+ <input type="text" name="myform" value="<?php echo html_escape($string); ?>" />
+
+.. note:: If you use any of the form helper functions listed in this page, the form
+ values will be prepped automatically, so there is no need to call this
+ function. Use it only if you are creating your own form elements. \ No newline at end of file
diff --git a/user_guide_src/source/helpers/string_helper.rst b/user_guide_src/source/helpers/string_helper.rst
index 19500aa0d..530af2f89 100644
--- a/user_guide_src/source/helpers/string_helper.rst
+++ b/user_guide_src/source/helpers/string_helper.rst
@@ -96,6 +96,9 @@ Generates repeating copies of the data you submit. Example
The above would generate 30 newlines.
+.. note:: This function is DEPRECATED. Use the native ``str_repeat()``
+ instead.
+
reduce_double_slashes()
=======================
diff --git a/user_guide_src/source/installation/upgrade_300.rst b/user_guide_src/source/installation/upgrade_300.rst
index 31a5c0761..6d99f4655 100644
--- a/user_guide_src/source/installation/upgrade_300.rst
+++ b/user_guide_src/source/installation/upgrade_300.rst
@@ -52,11 +52,12 @@ Step 5: Update your config/database.php
***************************************
Due to 3.0.0's renaming of Active Record to Query Builder, inside your `config/database.php`, you will
-need to rename the `$active_record` variable to `$query_builder`.
+need to rename the `$active_record` variable to `$query_builder`
+::
- $active_group = 'default';
- // $active_record = TRUE;
- $query_builder = TRUE;
+ $active_group = 'default';
+ // $active_record = TRUE;
+ $query_builder = TRUE;
*******************************
Step 6: Move your errors folder
@@ -64,16 +65,53 @@ Step 6: Move your errors folder
In version 3.0.0, the errors folder has been moved from _application/errors* to _application/views/errors*.
+*******************************************************
+Step 7: Update your config/routes.php containing (:any)
+*******************************************************
+
+Historically, CodeIgniter has always provided the **:any** wildcard in routing,
+with the intention of providing a way to match any character **within** an URI segment.
+
+However, the **:any** wildcard is actually just an alias for a regular expression
+and used to be executed in that manner as **.+**. This is considered a bug, as it
+also matches the / (forward slash) character, which is the URI segment delimiter
+and that was never the intention. In CodeIgniter 3, the **:any** wildcard will now
+represent **[^/]+**, so that it will not match a forward slash.
+
+There are certainly many developers that have utilized this bug as an actual feature.
+If you're one of them and want to match a forward slash, please use the **.+**
+regular expression::
+
+ (.+) // matches ANYTHING
+ (:any) // matches any character, except for '/'
+
+
****************************************************************************
-Step 7: Check the calls to Array Helper's element() and elements() functions
+Step 8: Check the calls to Array Helper's element() and elements() functions
****************************************************************************
The default return value of these functions, when the required elements
don't exist, has been changed from FALSE to NULL.
-***************************************************************
-Step 8: Remove usage of (previously) deprecated functionalities
-***************************************************************
+**********************************************************
+Step 9: Change usage of Email library with multiple emails
+**********************************************************
+
+The :doc:`Email library <../libraries/email>` will automatically clear the
+set parameters after successfully sending emails. To override this behaviour,
+pass FALSE as the first parameter in the ``send()`` method:
+
+::
+
+ if ($this->email->send(FALSE))
+ {
+ // Parameters won't be cleared
+ }
+
+
+****************************************************************
+Step 10: Remove usage of (previously) deprecated functionalities
+****************************************************************
In addition to the ``$autoload['core']`` configuration setting, there's a number of other functionalities
that have been removed in CodeIgniter 3.0.0:
@@ -118,6 +156,26 @@ CodeIgniter 3.1+.
.. note:: This function is still available, but you're strongly encouraged to remove it's usage sooner
rather than later.
+String helper repeater()
+========================
+
+:doc:`String Helper <../helpers/string_helper>` function ``repeater()`` is now just an alias for
+PHP's native ``str_repeat()`` function. It is deprecated and scheduled for removal in
+CodeIgniter 3.1+.
+
+.. note:: This function is still available, but you're strongly encouraged to remove it's usage sooner
+ rather than later.
+
+Form helper form_prep()
+=======================
+
+:doc:`Form Helper <../helpers/form_helper>` function ``form_prep()`` is now just an alias for
+:doc:`common function <../general/common_functions>` ``html_escape()`` and it's second argument
+is ignored. It is deprecated and scheduled for removal in CodeIgniter 3.1+.
+
+.. note:: This function is still available, but you're strongly encouraged to remove it's usage sooner
+ rather than later.
+
Date helper standard_date()
===========================
@@ -154,17 +212,4 @@ As a result of that, the 'anchor_class' setting is now deprecated and scheduled
CodeIgniter 3.1+.
.. note:: This setting is still available, but you're strongly encouraged to remove its' usage sooner
- rather than later.
-
-Email library
-=============
-
-The :doc:`Email library <../libraries/email>` will automatically clear the set parameters after successfully sending
-emails. To override this behaviour, pass FALSE as the first parameter in the ``send()`` function:
-
-::
-
- if ($this->email->send(FALSE))
- {
- // Parameters won't be cleared
- }
+ rather than later. \ No newline at end of file
diff --git a/user_guide_src/source/libraries/caching.rst b/user_guide_src/source/libraries/caching.rst
index 2f06d29f9..8d7b4c440 100644
--- a/user_guide_src/source/libraries/caching.rst
+++ b/user_guide_src/source/libraries/caching.rst
@@ -32,6 +32,17 @@ available in the hosting environment.
echo $foo;
+You can also prefix cache item names via the **key_prefix** setting, which is useful
+to avoid collisions when you're running multiple applications on the same environment.
+
+::
+
+ $this->load->driver('cache',
+ array('adapter' => 'apc', 'backup' => 'file', 'key_prefix' => 'my_')
+ );
+
+ $this->cache->get('foo'); // Will get the cache entry named 'my_foo'
+
******************
Function Reference
******************
@@ -39,7 +50,7 @@ Function Reference
.. php:class:: CI_Cache
is_supported()
-===============
+==============
.. php:method:: is_supported ( $driver )
@@ -130,7 +141,7 @@ clean()
$this->cache->clean();
cache_info()
-=============
+============
.. php:method:: cache_info ( )
@@ -148,7 +159,7 @@ cache_info()
get_metadata()
-===============
+==============
.. php:method:: get_metadata ( $id )
@@ -166,7 +177,6 @@ get_metadata()
.. note:: The information returned and the structure of the data is dependent
on which adapter is being used.
-
*******
Drivers
*******
@@ -181,7 +191,7 @@ specific adapter to the driver loader as follows::
$this->cache->apc->save('foo', 'bar', 10);
For more information on APC, please see
-`http://php.net/apc <http://php.net/apc>`_
+`http://php.net/apc <http://php.net/apc>`_.
File-based Caching
==================
@@ -201,20 +211,49 @@ Memcached Caching
=================
Multiple Memcached servers can be specified in the memcached.php
-configuration file, located in the application/config/ directory.
+configuration file, located in the _application/config/* directory.
-All of the functions listed above can be accessed without passing a
+All of the methods listed above can be accessed without passing a
specific adapter to the driver loader as follows::
$this->load->driver('cache');
$this->cache->memcached->save('foo', 'bar', 10);
For more information on Memcached, please see
-`http://php.net/memcached <http://php.net/memcached>`_
+`http://php.net/memcached <http://php.net/memcached>`_.
+
+WinCache Caching
+================
+
+Under Windows, you can also utilize the WinCache driver.
+
+All of the functions listed above can be accessed without passing a
+specific adapter to the driver loader as follows::
+
+ $this->load->driver('cache');
+ $this->cache->wincache->save('foo', 'bar', 10);
+
+For more information on WinCache, please see
+`http://php.net/wincache <http://php.net/wincache>`_.
+
+Redis Caching
+=============
+
+All of the methods listed above can be accessed without passing a
+specific adapter to the driver loader as follows::
+
+ $this->load->driver('cache');
+ $this->cache->redis->save('foo', 'bar', 10);
+
+.. important:: Redis may require one or more of the following options:
+ **host**, **post**, **timeout**, **password**.
+
+The Redis PHP extension repository is located at
+`https://github.com/nicolasff/phpredis <https://github.com/nicolasff/phpredis>`_.
Dummy Cache
===========
This is a caching backend that will always 'miss.' It stores no data,
but lets you keep your caching code in place in environments that don't
-support your chosen cache.
+support your chosen cache. \ No newline at end of file
diff --git a/user_guide_src/source/libraries/cart.rst b/user_guide_src/source/libraries/cart.rst
index 6594b3b9a..716e94bcb 100644
--- a/user_guide_src/source/libraries/cart.rst
+++ b/user_guide_src/source/libraries/cart.rst
@@ -279,16 +279,22 @@ by which this is returned by passing it "true" where the contents will be sorted
from newest to oldest, by leaving this function blank, you'll automatically just get
first added to the basket to last added to the basket.
-$this->cart->has_options(rowid);
-********************************
+$this->cart->get_item($row_id);
+*******************************
+
+Returns an array containing data for the item matching the specified row ID,
+or FALSE if no such item exists.
+
+$this->cart->has_options($row_id);
+**********************************
Returns TRUE (boolean) if a particular row in the cart contains options.
This function is designed to be used in a loop with
$this->cart->contents(), since you must pass the rowid to this function,
as shown in the Displaying the Cart example above.
-$this->cart->product_options(rowid);
-************************************
+$this->cart->product_options($row_id);
+**************************************
Returns an array of options for a particular product. This function is
designed to be used in a loop with $this->cart->contents(), since you
diff --git a/user_guide_src/source/libraries/form_validation.rst b/user_guide_src/source/libraries/form_validation.rst
index 6c6743d06..4d1940212 100644
--- a/user_guide_src/source/libraries/form_validation.rst
+++ b/user_guide_src/source/libraries/form_validation.rst
@@ -254,30 +254,30 @@ Setting Rules Using an Array
Before moving on it should be noted that the rule setting function can
be passed an array if you prefer to set all your rules in one action. If
-you use this approach you must name your array keys as indicated::
+you use this approach, you must name your array keys as indicated::
$config = array(
- array(
- 'field' => 'username',
- 'label' => 'Username',
- 'rules' => 'required'
- ),
- array(
- 'field' => 'password',
- 'label' => 'Password',
- 'rules' => 'required'
- ),
- array(
- 'field' => 'passconf',
- 'label' => 'Password Confirmation',
- 'rules' => 'required'
- ),
- array(
- 'field' => 'email',
- 'label' => 'Email',
- 'rules' => 'required'
- )
- );
+ array(
+ 'field' => 'username',
+ 'label' => 'Username',
+ 'rules' => 'required'
+ ),
+ array(
+ 'field' => 'password',
+ 'label' => 'Password',
+ 'rules' => 'required'
+ ),
+ array(
+ 'field' => 'passconf',
+ 'label' => 'Password Confirmation',
+ 'rules' => 'required'
+ ),
+ array(
+ 'field' => 'email',
+ 'label' => 'Email',
+ 'rules' => 'required'
+ )
+ );
$this->form_validation->set_rules($config);
@@ -291,7 +291,6 @@ your rules in the third parameter of rule setting function, like this::
$this->form_validation->set_rules('password', 'Password', 'required|matches[passconf]');
$this->form_validation->set_rules('passconf', 'Password Confirmation', 'required');
$this->form_validation->set_rules('email', 'Email', 'required|valid_email|is_unique[users.email]');
-
The above code sets the following rules:
@@ -560,11 +559,10 @@ globally, individually, or change the defaults in a config file.
#. **Set delimiters in a config file**
You can add your error delimiters in application/config/form_validation.php as follows::
-
+
$config['error_prefix'] = '<div class="error_prefix">';
$config['error_suffix'] = '</div>';
-
Showing Errors Individually
===========================
@@ -592,8 +590,8 @@ Try it! Change your form so that it looks like this::
If there are no errors, nothing will be shown. If there is an error, the
message will appear.
-**Important Note:** If you use an array as the name of a form field, you
-must supply it as an array to the function. Example::
+.. important:: If you use an array as the name of a form field, you
+ must supply it as an array to the function. Example::
<?php echo form_error('options[size]'); ?>
<input type="text" name="options[size]" value="<?php echo set_value("options[size]"); ?>" size="50" />
@@ -603,20 +601,20 @@ For more info please see the :ref:`using-arrays-as-field-names` section below.
Validating an Array (other than $_POST)
=======================================
-Sometimes you may want to validate an array that does not originate from $_POST data.
+Sometimes you may want to validate an array that does not originate from ``$_POST`` data.
In this case, you can specify the array to be validated::
-
+
$data = array(
- 'username' => 'johndoe',
- 'password' => 'mypassword',
- 'passconf' => 'mypassword'
- );
+ 'username' => 'johndoe',
+ 'password' => 'mypassword',
+ 'passconf' => 'mypassword'
+ );
$this->form_validation->set_data($data);
-Creating validation rules, running the validation and retrieving error messages works the same whether you are
-validating $_POST data or an array.
+Creating validation rules, running the validation and retrieving error messages works the
+same whether you are validating ``$_POST`` data or an array.
**Important Note:** If you want to validate more than one array during a single execution, then you should
call the reset_validation() function before setting up rules and validating the new array.
@@ -644,32 +642,32 @@ you will place an array named $config with your rules. As shown earlier,
the validation array will have this prototype::
$config = array(
- array(
- 'field' => 'username',
- 'label' => 'Username',
- 'rules' => 'required'
- ),
- array(
- 'field' => 'password',
- 'label' => 'Password',
- 'rules' => 'required'
- ),
- array(
- 'field' => 'passconf',
- 'label' => 'Password Confirmation',
- 'rules' => 'required'
- ),
- array(
- 'field' => 'email',
- 'label' => 'Email',
- 'rules' => 'required'
- )
- );
+ array(
+ 'field' => 'username',
+ 'label' => 'Username',
+ 'rules' => 'required'
+ ),
+ array(
+ 'field' => 'password',
+ 'label' => 'Password',
+ 'rules' => 'required'
+ ),
+ array(
+ 'field' => 'passconf',
+ 'label' => 'Password Confirmation',
+ 'rules' => 'required'
+ ),
+ array(
+ 'field' => 'email',
+ 'label' => 'Email',
+ 'rules' => 'required'
+ )
+ );
Your validation rule file will be loaded automatically and used when you
-call the run() function.
+call the ``run()`` method.
-Please note that you MUST name your array $config.
+Please note that you MUST name your ``$config`` array.
Creating Sets of Rules
======================
@@ -729,45 +727,44 @@ You can name your rules anything you want::
Calling a Specific Rule Group
=============================
-In order to call a specific group you will pass its name to the run()
-function. For example, to call the signup rule you will do this::
+In order to call a specific group you will pass its name to the ``run()``
+method. For example, to call the signup rule you will do this::
if ($this->form_validation->run('signup') == FALSE)
{
- $this->load->view('myform');
+ $this->load->view('myform');
}
else
{
- $this->load->view('formsuccess');
+ $this->load->view('formsuccess');
}
Associating a Controller Function with a Rule Group
===================================================
An alternate (and more automatic) method of calling a rule group is to
-name it according to the controller class/function you intend to use it
+name it according to the controller class/method you intend to use it
with. For example, let's say you have a controller named Member and a
-function named signup. Here's what your class might look like::
+method named signup. Here's what your class might look like::
<?php
class Member extends CI_Controller {
- function signup()
- {
- $this->load->library('form_validation');
-
- if ($this->form_validation->run() == FALSE)
- {
- $this->load->view('myform');
- }
- else
- {
- $this->load->view('formsuccess');
- }
- }
+ function signup()
+ {
+ $this->load->library('form_validation');
+
+ if ($this->form_validation->run() == FALSE)
+ {
+ $this->load->view('myform');
+ }
+ else
+ {
+ $this->load->view('formsuccess');
+ }
+ }
}
- ?>
In your validation config file, you will name your rule group
member/signup::
@@ -913,6 +910,9 @@ Rule Parameter Description
to two parameters, where at least one is required (to pass
the field data).
+.. note:: When using the **matches** rule, the form item specified
+ to compare against must already be defined.
+
******************
Prepping Reference
******************
@@ -945,7 +945,7 @@ The following functions are intended for use in your controller
functions.
$this->form_validation->set_rules();
-======================================
+====================================
.. php:method:: set_rules ($field, $label = '', $rules = '')
@@ -953,7 +953,7 @@ $this->form_validation->set_rules();
:param string $label: The field label
:param mixed $rules: The rules, as a string with rules separated by a pipe "|", or an array or rules.
:rtype: Object
-
+
Permits you to set validation rules, as described in the tutorial
sections above:
@@ -961,19 +961,19 @@ $this->form_validation->set_rules();
- :ref:`saving-groups`
$this->form_validation->run();
-===============================
+==============================
.. php:method:: run ($group = '')
:param string $group: The name of the validation group to run
:rtype: Boolean
-
+
Runs the validation routines. Returns boolean TRUE on success and FALSE
on failure. You can optionally pass the name of the validation group via
the function, as described in: :ref:`saving-groups`
$this->form_validation->set_message();
-========================================
+======================================
.. php:method:: set_message ($lang, $val = '')
@@ -984,7 +984,7 @@ $this->form_validation->set_message();
Permits you to set custom error messages. See :ref:`setting-error-messages`
$this->form_validation->set_data();
-========================================
+===================================
.. php:method:: set_data ($data = '')
@@ -996,13 +996,13 @@ $this->form_validation->set_data();
$this->form_validation->reset_validation();
===========================================
- .. php:method:: reset_validation ()
+ .. php:method:: reset_validation ()
- Permits you to reset the validation when you validate more than one array.
- This function should be called before validating each new array.
+ Permits you to reset the validation when you validate more than one array.
+ This method should be called before validating each new array.
$this->form_validation->error_array();
-========================================
+======================================
.. php:method:: error_array ()
@@ -1021,7 +1021,7 @@ containing your forms. Note that these are procedural functions, so they
**do not** require you to prepend them with $this->form_validation.
form_error()
-=============
+============
Shows an individual error message associated with the field name
supplied to the function. Example::
@@ -1032,7 +1032,7 @@ The error delimiters can be optionally specified. See the
:ref:`changing-delimiters` section above.
validation_errors()
-====================
+===================
Shows all error messages as a string: Example::
@@ -1042,7 +1042,7 @@ The error delimiters can be optionally specified. See the
:ref:`changing-delimiters` section above.
set_value()
-============
+===========
Permits you to set the value of an input form or textarea. You must
supply the field name via the first parameter of the function. The
@@ -1054,7 +1054,7 @@ form. Example::
The above form will show "0" when loaded for the first time.
set_select()
-=============
+============
If you use a <select> menu, this function permits you to display the
menu item that was selected. The first parameter must contain the name
@@ -1071,7 +1071,7 @@ Example::
</select>
set_checkbox()
-===============
+==============
Permits you to display a checkbox in the state it was submitted. The
first parameter must contain the name of the checkbox, the second
@@ -1082,7 +1082,7 @@ lets you set an item as the default (use boolean TRUE/FALSE). Example::
<input type="checkbox" name="mycheck[]" value="2" <?php echo set_checkbox('mycheck[]', '2'); ?> />
set_radio()
-============
+===========
Permits you to display radio buttons in the state they were submitted.
This function is identical to the **set_checkbox()** function above.
@@ -1090,4 +1090,4 @@ This function is identical to the **set_checkbox()** function above.
::
<input type="radio" name="myradio" value="1" <?php echo set_radio('myradio', '1', TRUE); ?> />
- <input type="radio" name="myradio" value="2" <?php echo set_radio('myradio', '2'); ?> />
+ <input type="radio" name="myradio" value="2" <?php echo set_radio('myradio', '2'); ?> /> \ No newline at end of file