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.rst5
-rw-r--r--user_guide_src/source/database/forge.rst14
-rw-r--r--user_guide_src/source/general/common_functions.rst12
-rw-r--r--user_guide_src/source/general/controllers.rst152
-rw-r--r--user_guide_src/source/installation/upgrade_300.rst30
-rw-r--r--user_guide_src/source/libraries/form_validation.rst3
6 files changed, 122 insertions, 94 deletions
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index abb75f579..717d7f6ba 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -154,6 +154,8 @@ Release Date: Not Released
- Added MySQL client compression support.
- Added encrypted connections support (for *mysql*, *sqlsrv* and PDO with *sqlsrv*).
- Removed :doc:`Loader Class <libraries/loader>` from Database error tracing to better find the likely culprit.
+ - Added an optional second parameter to ``drop_table()`` in :doc:`Database Forge <database/forge>` that allows adding the IF EXISTS condition.
+ - Removed the optional AFTER clause from :doc:`Database Forge <database/forge>` method ``add_column()``.
- Libraries
@@ -182,7 +184,7 @@ Release Date: Not Released
- 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.
+ - 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.
- Class properties *wm_font_color*, *wm_shadow_color* and *wm_use_drop_shadow* are now protected, to avoid breaking the ``text_watermark()`` method if they are set manually after initialization.
- If property *maintain_ratio* is set to TRUE, ``image_reproportion()`` now doesn't need both width and height to be specified.
@@ -245,7 +247,6 @@ Release Date: Not Released
- ``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.
- - Removed method ``initialize()`` and moved its logic to the constructor.
- :doc:`Input Library <libraries/input>` changes include:
- Added ``method()`` to retrieve ``$_SERVER['REQUEST_METHOD']``.
- Added support for arrays and network addresses (e.g. 192.168.1.1/24) for use with the *proxy_ips* setting.
diff --git a/user_guide_src/source/database/forge.rst b/user_guide_src/source/database/forge.rst
index bf17e2918..1d6b847b4 100644
--- a/user_guide_src/source/database/forge.rst
+++ b/user_guide_src/source/database/forge.rst
@@ -193,13 +193,15 @@ into the definition
Dropping a table
================
-Executes a DROP TABLE sql
+Execute a DROP TABLE statement and optionally add an IF EXISTS clause.
::
+ // Produces: DROP TABLE table_name
$this->dbforge->drop_table('table_name');
- // gives DROP TABLE IF EXISTS table_name
+ // Produces: DROP TABLE IF EXISTS table_name
+ $this->dbforge->drop_table('table_name');
Renaming a table
================
@@ -231,14 +233,6 @@ number of additional fields.
$this->dbforge->add_column('table_name', $fields);
// gives ALTER TABLE table_name ADD preferences TEXT
-An optional third parameter can be used to specify which existing column
-to add the new column after.
-
-::
-
- $this->dbforge->add_column('table_name', $fields, 'after_field');
-
-
$this->dbforge->drop_column()
==============================
diff --git a/user_guide_src/source/general/common_functions.rst b/user_guide_src/source/general/common_functions.rst
index f3d48ac91..7f327f00b 100644
--- a/user_guide_src/source/general/common_functions.rst
+++ b/user_guide_src/source/general/common_functions.rst
@@ -46,10 +46,14 @@ recommended on platforms where this information may be unreliable.
config_item('item_key')
=======================
-The :doc:`Config library <../libraries/config>` is the preferred way of
-accessing configuration information, however config_item() can be used
-to retrieve single keys. See Config library documentation for more
-information.
+The :doc:`Config Library <../libraries/config>` is the preferred way of
+accessing configuration information, however ``config_item()`` can be used
+to retrieve single keys. See :doc:`Config Library <../libraries/config>`
+documentation for more information.
+
+.. important:: This function only returns values set in your configuration
+ files. It does not take into account config values that are
+ dynamically set at runtime.
show_error('message'), show_404('page'), log_message('level', 'message')
========================================================================
diff --git a/user_guide_src/source/general/controllers.rst b/user_guide_src/source/general/controllers.rst
index 6e5079419..150d2269c 100644
--- a/user_guide_src/source/general/controllers.rst
+++ b/user_guide_src/source/general/controllers.rst
@@ -67,21 +67,21 @@ This is **not** valid::
?>
Also, always make sure your controller extends the parent controller
-class so that it can inherit all its functions.
+class so that it can inherit all its methods.
-Functions
-=========
+Methods
+=======
-In the above example the function name is index(). The "index" function
+In the above example the method name is ``index()``. The "index" method
is always loaded by default if the **second segment** of the URI is
empty. Another way to show your "Hello World" message would be this::
example.com/index.php/blog/index/
-**The second segment of the URI determines which function in the
+**The second segment of the URI determines which method in the
controller gets called.**
-Let's try it. Add a new function to your controller::
+Let's try it. Add a new method to your controller::
<?php
class Blog extends CI_Controller {
@@ -98,37 +98,37 @@ Let's try it. Add a new function to your controller::
}
?>
-Now load the following URL to see the comment function::
+Now load the following URL to see the comment method::
example.com/index.php/blog/comments/
You should see your new message.
-Passing URI Segments to your Functions
-======================================
+Passing URI Segments to your methods
+====================================
If your URI contains more then two segments they will be passed to your
-function as parameters.
+method as parameters.
For example, lets say you have a URI like this::
example.com/index.php/products/shoes/sandals/123
-Your function will be passed URI segments 3 and 4 ("sandals" and "123")::
+Your method will be passed URI segments 3 and 4 ("sandals" and "123")::
<?php
class Products extends CI_Controller {
- public function shoes($sandals, $id)
- {
- echo $sandals;
- echo $id;
- }
+ public function shoes($sandals, $id)
+ {
+ echo $sandals;
+ echo $id;
+ }
}
?>
.. important:: If you are using the :doc:`URI Routing <routing>`
- feature, the segments passed to your function will be the re-routed
+ feature, the segments passed to your method will be the re-routed
ones.
Defining a Default Controller
@@ -145,53 +145,53 @@ Where Blog is the name of the controller class you want used. If you now
load your main index.php file without specifying any URI segments you'll
see your Hello World message by default.
-Remapping Function Calls
-========================
+Remapping Method Calls
+======================
As noted above, the second segment of the URI typically determines which
-function in the controller gets called. CodeIgniter permits you to
-override this behavior through the use of the _remap() function::
+method in the controller gets called. CodeIgniter permits you to override
+this behavior through the use of the ``_remap()`` method::
public function _remap()
{
- // Some code here...
+ // Some code here...
}
-.. important:: If your controller contains a function named _remap(),
+.. important:: If your controller contains a method named _remap(),
it will **always** get called regardless of what your URI contains. It
- overrides the normal behavior in which the URI determines which function
- is called, allowing you to define your own function routing rules.
+ overrides the normal behavior in which the URI determines which method
+ is called, allowing you to define your own method routing rules.
-The overridden function call (typically the second segment of the URI)
-will be passed as a parameter to the _remap() function::
+The overridden method call (typically the second segment of the URI) will
+be passed as a parameter to the ``_remap()`` method::
public function _remap($method)
{
- if ($method == 'some_method')
- {
- $this->$method();
- }
- else
- {
- $this->default_method();
- }
+ if ($method == 'some_method')
+ {
+ $this->$method();
+ }
+ else
+ {
+ $this->default_method();
+ }
}
-Any extra segments after the method name are passed into _remap() as an
+Any extra segments after the method name are passed into ``_remap()`` as an
optional second parameter. This array can be used in combination with
-PHP's `call_user_func_array <http://php.net/call_user_func_array>`_
+PHP's `call_user_func_array() <http://php.net/call_user_func_array>`_
to emulate CodeIgniter's default behavior.
::
public function _remap($method, $params = array())
{
- $method = 'process_'.$method;
- if (method_exists($this, $method))
- {
- return call_user_func_array(array($this, $method), $params);
- }
- show_404();
+ $method = 'process_'.$method;
+ if (method_exists($this, $method))
+ {
+ return call_user_func_array(array($this, $method), $params);
+ }
+ show_404();
}
Processing Output
@@ -199,29 +199,29 @@ Processing Output
CodeIgniter has an output class that takes care of sending your final
rendered data to the web browser automatically. More information on this
-can be found in the :doc:`Views <views>` and :doc:`Output class <../libraries/output>` pages. In some cases, however, you
-might want to post-process the finalized data in some way and send it to
-the browser yourself. CodeIgniter permits you to add a function named
-_output() to your controller that will receive the finalized output
-data.
+can be found in the :doc:`Views <views>` and :doc:`Output Class
+<../libraries/output>` pages. In some cases, however, you might want to
+post-process the finalized data in some way and send it to the browser
+yourself. CodeIgniter permits you to add a method named ``_output()``
+to your controller that will receive the finalized output data.
-.. important:: If your controller contains a function named _output(),
- it will **always** be called by the output class instead of echoing the
- finalized data directly. The first parameter of the function will
- contain the finalized output.
+.. important:: If your controller contains a method named _output(), it
+ will **always** be called by the output class instead of echoing
+ the finalized data directly. The first parameter of the method
+ will contain the finalized output.
Here is an example::
public function _output($output)
{
- echo $output;
+ echo $output;
}
-.. note:: Please note that your _output() function will receive the data in its
+.. note:: Please note that your _output() method will receive the data in its
finalized state. Benchmark and memory usage data will be rendered, cache
files written (if you have caching enabled), and headers will be sent
(if you use that :doc:`feature <../libraries/output>`) before it is
- handed off to the _output() function.
+ handed off to the _output() method.
To have your controller's output cached properly, its _output() method
can use::
@@ -236,23 +236,27 @@ Here is an example::
output *before* any of the final processing is done, please see the
available methods in the :doc:`Output Class <../libraries/output>`.
-Private Functions
-=================
+Private methods
+===============
-In some cases you may want certain functions hidden from public access.
-To make a function private, simply add an underscore as the name prefix
-and it will not be served via a URL request. For example, if you were to
-have a function like this::
+In some cases you may want certain methods hidden from public access.
+In order to achieve this, simply declare the method as being private
+or protected and it will not be served via a URL request. For example,
+if you were to have a method like this::
private function _utility()
{
- // some code
+ // some code
}
Trying to access it via the URL, like this, will not work::
example.com/index.php/blog/_utility/
+.. note:: Prefixing method names with an underscore will also prevent
+ them from being called. This is a legacy feature that is left
+ for backwards-compatibility.
+
Organizing Your Controllers into Sub-folders
============================================
@@ -297,11 +301,11 @@ manually call it.
<?php
class Blog extends CI_Controller {
- public function __construct()
- {
- parent::__construct();
- // Your own constructor code
- }
+ public function __construct()
+ {
+ parent::__construct();
+ // Your own constructor code
+ }
}
?>
@@ -309,16 +313,22 @@ Constructors are useful if you need to set some default values, or run a
default process when your class is instantiated. Constructors can't
return a value, but they can do some default work.
-Reserved Function Names
-=======================
+Reserved method names
+=====================
Since your controller classes will extend the main application
-controller you must be careful not to name your functions identically to
+controller you must be careful not to name your methods identically to
the ones used by that class, otherwise your local functions will
override them. See :doc:`Reserved Names <reserved_names>` for a full
list.
+.. important:: You should also never have a method named identically
+ to its class name. If you do, and there is no __construct()
+ method in the same class, then your e.g. Index::index() method
+ will be executed as a class constructor! This is a PHP4
+ backwards-compatibility feature.
+
That's it!
==========
-That, in a nutshell, is all there is to know about controllers.
+That, in a nutshell, is all there is to know about controllers. \ No newline at end of file
diff --git a/user_guide_src/source/installation/upgrade_300.rst b/user_guide_src/source/installation/upgrade_300.rst
index fd5eea478..4e0b952d5 100644
--- a/user_guide_src/source/installation/upgrade_300.rst
+++ b/user_guide_src/source/installation/upgrade_300.rst
@@ -93,9 +93,31 @@ 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 9: Change usage of Email library with multiple emails
-**********************************************************
+************************************************************
+Step 9: Update usage of Database Forge's drop_table() method
+************************************************************
+
+Up until now, ``drop_table()`` added an IF EXISTS clause by default or it didn't work
+at all with some drivers. In CodeIgniter 3.0, the IF EXISTS condition is no longer added
+by deafault and has an optional second parameter that allows that instead and is set to
+FALSE by default.
+
+If your application relies on IF EXISTS, you'll have to change its usage.
+
+::
+
+ // Now produces just DROP TABLE `table_name`
+ $this->dbforge->drop_table('table_name');
+
+ // Produces DROP TABLE IF EXISTS `table_name`
+ $this->dbforge->drop_table('table_name', TRUE);
+
+.. note:: The given example users MySQL-specific syntax, but it should work across
+ all drivers with the exception of ODBC.
+
+***********************************************************
+Step 10: 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,
@@ -110,7 +132,7 @@ pass FALSE as the first parameter in the ``send()`` method:
****************************************************************
-Step 10: Remove usage of (previously) deprecated functionalities
+Step 11: Remove usage of (previously) deprecated functionalities
****************************************************************
In addition to the ``$autoload['core']`` configuration setting, there's a number of other functionalities
diff --git a/user_guide_src/source/libraries/form_validation.rst b/user_guide_src/source/libraries/form_validation.rst
index c010eb578..a3a35b499 100644
--- a/user_guide_src/source/libraries/form_validation.rst
+++ b/user_guide_src/source/libraries/form_validation.rst
@@ -910,9 +910,6 @@ 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
******************