From e334c472fb4be44feec3a73402fc4a2b062cbfc0 Mon Sep 17 00:00:00 2001 From: admin Date: Sat, 21 Oct 2006 19:44:22 +0000 Subject: --- user_guide/database/active_record.html | 14 +++++++------- user_guide/database/caching.html | 24 ++++++++++++------------ user_guide/database/call_function.html | 8 ++++---- user_guide/database/configuration.html | 28 ++++++++++++++-------------- user_guide/database/connecting.html | 12 ++++++------ user_guide/database/examples.html | 4 ++-- user_guide/database/fields.html | 6 +++--- user_guide/database/helpers.html | 2 +- user_guide/database/index.html | 2 +- user_guide/database/queries.html | 10 +++++----- user_guide/database/results.html | 6 +++--- user_guide/database/table_data.html | 2 +- user_guide/database/transactions.html | 8 ++++---- user_guide/database/utilities.html | 10 +++++----- 14 files changed, 68 insertions(+), 68 deletions(-) (limited to 'user_guide/database') diff --git a/user_guide/database/active_record.html b/user_guide/database/active_record.html index f30b3d8b6..b5c94a2cd 100644 --- a/user_guide/database/active_record.html +++ b/user_guide/database/active_record.html @@ -12,7 +12,7 @@ @@ -66,9 +66,9 @@ Active Record

Active Record Class

-

Code Igniter uses a modified version of the Active Record Database Pattern. -This pattern allows information to be retrieved, inserted, and updated in your database with minimal scripting. -In some cases only one or two lines of code are necessary to perform a database action. +

Code Igniter uses a modified version of the Active Record Database Pattern. +This pattern allows information to be retrieved, inserted, and updated in your database with minimal scripting. +In some cases only one or two lines of code are necessary to perform a database action. Code Igniter does not require that each database table be its own class file. It instead provides a more simplified interface.

Beyond simplicity, a major benefit to using the Active Record features is that it allows you to create database independent applications, since the query syntax @@ -182,7 +182,7 @@ $query = $this->db->get();

Multiple function calls can be made if you need several joins in one query.

-

If you need something other than a natural JOIN you can specify it via the third parameter of the function. +

If you need something other than a natural JOIN you can specify it via the third parameter of the function. Options are: left, right, outer, inner, left outer, and right outer.

@@ -353,7 +353,7 @@ $this->db->orlike('body', $match);

$this->db->orderby();

-

Lets you set an ORDER BY clause. The first parameter contains the name of the column you would like to order by. +

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 asc or desc or RAND()

$this->db->orderby("title", "desc"); @@ -563,7 +563,7 @@ $this->db->delete('mytable', array('id' => $id)); // DELETE FROM mytable
// WHERE id = $id
-

The first parameter is the table name, the second is the where clause. You can also use the where() or orwhere() functions instead of passing +

The first parameter is the table name, the second is the where clause. You can also use the where() or orwhere() functions instead of passing the data to the second parameter of the function: diff --git a/user_guide/database/caching.html b/user_guide/database/caching.html index 8a43268e9..ce5535c23 100644 --- a/user_guide/database/caching.html +++ b/user_guide/database/caching.html @@ -12,7 +12,7 @@ @@ -86,24 +86,24 @@ when caching is enabled. Do NOT load this class manually.

How Does Caching Work?

-

Code Igniter's query caching system happens dynamically when your pages are viewed. +

Code Igniter's query caching system happens dynamically when your pages are viewed. When caching is enabled, the first time a web page is loaded, the query result object will be serialized and stored in a text file on your server. The next time the page is loaded the cache file will be used instead of accessing your database. Your database usage can effectively be reduced to zero for any pages that have been cached.

-

Only read-type (SELECT) queries can be cached, since these are the only type of queries that produce a result. +

Only read-type (SELECT) queries can be cached, since these are the only type of queries that produce a result. Write-type (INSERT, UPDATE, etc.) queries, since they don't generate a result, will not be cached by the system.

-

Cache files DO NOT expire. Any queries that have been cached will remain cached until you delete them. The caching system -permits you clear caches associated with individual pages, or you can delete the entire collection of cache files. +

Cache files DO NOT expire. Any queries that have been cached will remain cached until you delete them. The caching system +permits you clear caches associated with individual pages, or you can delete the entire collection of cache files. Typically you'll to use the housekeeping functions described below to delete cache files after certain events take place, like when you've added new information to your database.

Will Caching Improve Your Site's Performance?

-

Getting a performance gain as a result of caching depends on many factors. +

Getting a performance gain as a result of caching depends on many factors. If you have a highly optimized database under very little load, you probably won't see a performance boost. -If your database is under heavy use you probably will see an improved response, assuming your file-system is not +If your database is under heavy use you probably will see an improved response, assuming your file-system is not overly taxed. Remember that caching simply changes how your information is retrieved, shifting it from being a database operation to a file-system one.

@@ -113,24 +113,24 @@ single answer to the question of whether you should cache your database. It rea

How are Cache Files Stored?

-

Code Igniter places the result of EACH query into its own cache file. Sets of cache files are further organized into +

Code Igniter places the result of EACH query into its own cache file. Sets of cache files are further organized into sub-folders corresponding to your controller functions. To be precise, the sub-folders are named identically to the first two segments of your URI (the controller class name and function name).

For example, let's say you have a controller called blog with a function called comments that -contains three queries. The caching system will create a cache folder +contains three queries. The caching system will create a cache folder called blog+comments, into which it will write three cache files.

If you use dynamic queries that change based on information in your URI (when using pagination, for example), each instance of -the query will produce its own cache file. It's possible, therefore, to end up with many times more cache files than you have +the query will produce its own cache file. It's possible, therefore, to end up with many times more cache files than you have queries.

Managing your Cache Files

Since cache files do not expire, you'll need to build deletion routines into your application. For example, let's say you have a blog -that allows user commenting. Whenever a new comment is submitted you'll want to delete the cache files associated with the -controller function that serves up your comments. You'll find two delete functions described below that help you +that allows user commenting. Whenever a new comment is submitted you'll want to delete the cache files associated with the +controller function that serves up your comments. You'll find two delete functions described below that help you clear data.

diff --git a/user_guide/database/call_function.html b/user_guide/database/call_function.html index 43bc9729c..a437b43aa 100644 --- a/user_guide/database/call_function.html +++ b/user_guide/database/call_function.html @@ -12,7 +12,7 @@ @@ -66,15 +66,15 @@ Custom Function Calls

$this->db->call_function();

-

This function enables you to call PHP database functions that are not natively included in Code Igniter, in a platform independent manner. -For example, lets say you want to call the mysql_get_client_info() function, which is not natively supported +

This function enables you to call PHP database functions that are not natively included in Code Igniter, in a platform independent manner. +For example, lets say you want to call the mysql_get_client_info() function, which is not natively supported by Code Igniter. You could do so like this:

$this->db->call_function('get_client_info');

You must supply the name of the function, without the mysql_ prefix, in the first parameter. The prefix is added -automatically based on which database driver is currently being used. This permits you to run the same function on different database platforms. +automatically based on which database driver is currently being used. This permits you to run the same function on different database platforms. Obviously not all function calls are identical between platforms, so there are limits to how useful this function can be in terms of portability.

Any parameters needed by the function you are calling will be added to the second parameter.

diff --git a/user_guide/database/configuration.html b/user_guide/database/configuration.html index ea287d770..830f81883 100644 --- a/user_guide/database/configuration.html +++ b/user_guide/database/configuration.html @@ -12,7 +12,7 @@ @@ -65,7 +65,7 @@ Configuration

Database Configuration

-

Code Igniter has a config file that lets you store your database connection values (username, password, database name, etc.). +

Code Igniter has a config file that lets you store your database connection values (username, password, database name, etc.). The config file is located at:

application/config/database.php

@@ -82,8 +82,8 @@ $db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = FALSE;
$db['default']['active_r'] = TRUE;
-

The reason we use a multi-dimensional array rather than a more simple one is to permit you to optionally store -multiple sets of connection values. If, for example, you run multiple environments (development, production, test, etc.) +

The reason we use a multi-dimensional array rather than a more simple one is to permit you to optionally store +multiple sets of connection values. If, for example, you run multiple environments (development, production, test, etc.) under a single installation, you can set up a connection group for each, then switch between groups as needed. For example, to set up a "test" environment you would do this:

@@ -97,7 +97,7 @@ $db['test']['pconnect'] = TRUE;
$db['test']['db_debug'] = FALSE;
$db['test']['active_r'] = TRUE;
- +

Then, to globally tell the system to use that group you would set this variable located in the config file:

$active_group = "test"; @@ -108,15 +108,15 @@ for the primary connection, but it too can be renamed to something more relevant

Explanation of Values:

diff --git a/user_guide/database/connecting.html b/user_guide/database/connecting.html index c057f69fe..ced947941 100644 --- a/user_guide/database/connecting.html +++ b/user_guide/database/connecting.html @@ -12,7 +12,7 @@ @@ -69,20 +69,20 @@ Connecting

Automatically Connecting

-

The "auto connect" feature will load and instantiate the database class with every page load. +

The "auto connect" feature will load and instantiate the database class with every page load. To enable "auto connecting", add the word database to the core array, as indicated in the following file:

application/config/autoload.php

Manually Connecting

-

If only some of your pages require database connectivity you can manually connect to your database by adding this -line of code in any function where it is needed, or in your class constructor to make the database +

If only some of your pages require database connectivity you can manually connect to your database by adding this +line of code in any function where it is needed, or in your class constructor to make the database available globally in that class.

$this->load->database(); -

If the above function does not contain any information in the first parameter it will connect +

If the above function does not contain any information in the first parameter it will connect to the group specified in your database config file. For most people, this is the preferred method of use.

@@ -133,7 +133,7 @@ $this->load->database('$dsn'); $DB2 = $this->load->database('group_two', TRUE); -

Note: Change the words "group_one" and "group_two" to the specific group names you are connecting to (or +

Note: Change the words "group_one" and "group_two" to the specific group names you are connecting to (or you can pass the connection values as indicated above).

By setting the second parameter to TRUE (boolean) the function will return the database object.

diff --git a/user_guide/database/examples.html b/user_guide/database/examples.html index 8916b5ee9..79631042a 100644 --- a/user_guide/database/examples.html +++ b/user_guide/database/examples.html @@ -12,7 +12,7 @@ @@ -182,7 +182,7 @@ foreach ($query->result() as $row)
    echo $row->title;
} -

The above get() function retrieves all the results from the supplied table. +

The above get() function retrieves all the results from the supplied table. The Active Record class contains a full compliment of functions for working with data.

diff --git a/user_guide/database/fields.html b/user_guide/database/fields.html index 1ae1a392b..8f206638f 100644 --- a/user_guide/database/fields.html +++ b/user_guide/database/fields.html @@ -12,7 +12,7 @@ @@ -80,7 +80,7 @@ foreach ($fields as $field)
} -

2. You can gather the field names associated with any query you run by calling the function +

2. You can gather the field names associated with any query you run by calling the function from your query result object:

@@ -106,7 +106,7 @@ if ($this->db->field_exists('field_name', 'table_name'))
}
-

Note: Replace field_name with the name of the column you are looking for, and replace +

Note: Replace field_name with the name of the column you are looking for, and replace table_name with the name of the table you are looking for.

diff --git a/user_guide/database/helpers.html b/user_guide/database/helpers.html index 102794b25..19fe47998 100644 --- a/user_guide/database/helpers.html +++ b/user_guide/database/helpers.html @@ -12,7 +12,7 @@ diff --git a/user_guide/database/index.html b/user_guide/database/index.html index 4f3876ec5..f83aab22b 100644 --- a/user_guide/database/index.html +++ b/user_guide/database/index.html @@ -12,7 +12,7 @@ diff --git a/user_guide/database/queries.html b/user_guide/database/queries.html index a13e2d6a5..e558e3d8b 100644 --- a/user_guide/database/queries.html +++ b/user_guide/database/queries.html @@ -12,7 +12,7 @@ @@ -81,24 +81,24 @@ depending on success or failure. When retrieving data you will typically assign

$this->db->simple_query();

This is a simplified version of the $this->db->query() function. It ONLY returns TRUE/FALSE on success or failure. -It DOES NOT return a database result set, nor does it set the query timer, or compile bind data, or store your query for debugging. +It DOES NOT return a database result set, nor does it set the query timer, or compile bind data, or store your query for debugging. It simply lets you submit a query. Most users will rarely use this function.

Escaping Queries

-

It's a very good security practice to escape your data before submitting it into your database. +

It's a very good security practice to escape your data before submitting it into your database. Code Igniter has two functions that help you do this:

    -
  1. $this->db->escape() This function determines the data type so that it +
  2. $this->db->escape() This function determines the data type so that it can escape only string data. It also automatically adds single quotes around the data so you don't have to: $sql = "INSERT INTO table (title) VALUES(".$this->db->escape($title).")"; -
  3. $this->db->escape_str() This function escapes the data passed to it, regardless of type. +
  4. $this->db->escape_str() This function escapes the data passed to it, regardless of type. Most of the time you'll use the above function rather then this one. Use the function like this: $sql = "INSERT INTO table (title) VALUES('".$this->db->escape_str($title)."')"; diff --git a/user_guide/database/results.html b/user_guide/database/results.html index a301bc3f9..bae8a75c7 100644 --- a/user_guide/database/results.html +++ b/user_guide/database/results.html @@ -12,7 +12,7 @@ @@ -119,7 +119,7 @@ Query Results

    row()

    -

    This function returns a single result row. If your query has more than one row, it returns only the first row. +

    This function returns a single result row. If your query has more than one row, it returns only the first row. The result is returned as an object. Here's a usage example:

    $query = $this->db->query("YOUR QUERY");
    @@ -161,7 +161,7 @@ Query Results $row = $query->row_array(5); - +

    In addition, you can walk forward/backwards/first/last through your results using these variations:

    diff --git a/user_guide/database/table_data.html b/user_guide/database/table_data.html index 511cc7810..681193366 100644 --- a/user_guide/database/table_data.html +++ b/user_guide/database/table_data.html @@ -12,7 +12,7 @@ diff --git a/user_guide/database/transactions.html b/user_guide/database/transactions.html index ef1f1a6e6..4677ed6ff 100644 --- a/user_guide/database/transactions.html +++ b/user_guide/database/transactions.html @@ -12,7 +12,7 @@ @@ -69,8 +69,8 @@ Transactions

    Code Igniter's database abstraction allows you to use transactions with databases that support transaction-safe table types. In MySQL, you'll need to be running InnoDB or BDB table types rather then the more common MyISAM. Most other database platforms support transactions natively.

    -

    If you are not familiar with -transactions we recommend you find a good online resource to learn about them for your particular database. The information below assumes you +

    If you are not familiar with +transactions we recommend you find a good online resource to learn about them for your particular database. The information below assumes you have a basic understanding of transactions.

    @@ -80,7 +80,7 @@ have a basic understanding of transactions. because it greatly simplifies the process of running transactions. In most cases all that is required are two lines of code.

    Traditionally, transactions have required a fair amount of work to implement since they demand that you to keep track of your queries -and determine whether to commit or rollback based on the success or failure of your queries. This is particularly cumbersome with +and determine whether to commit or rollback based on the success or failure of your queries. This is particularly cumbersome with nested queries. In contrast, we've implemented a smart transaction system that does all this for you automatically (you can also manage your transactions manually if you choose to, but there's really no benefit).

    diff --git a/user_guide/database/utilities.html b/user_guide/database/utilities.html index f1692808f..cbc791537 100644 --- a/user_guide/database/utilities.html +++ b/user_guide/database/utilities.html @@ -12,7 +12,7 @@ @@ -193,7 +193,7 @@ if ($result !== FALSE)

    $this->dbutil->csv_from_result($db_result)

    -

    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. +

    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:

    @@ -204,7 +204,7 @@ $query = $this->db->query("SELECT * FROM mytable");
    echo $this->dbutil->csv_from_result($query);
    -

    The second and third parameters allows you to +

    The second and third parameters allows you to set the delimiter and newline character. By default tabs are used as the delimiter and "\n" is used as a new line. Example: @@ -221,7 +221,7 @@ If you need to write the file use the File

    $this->dbutil->xml_from_result($db_result)

    -

    Permits you to generate an XML file from a query result. The first parameter expects a query result object, the second +

    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:

    @@ -251,7 +251,7 @@ If you need to write the file use the File

    Note:  This features is only available for MySQL/MySQLi databases.

    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 very large you might need to backup directly from your SQL server +databases may not be possible. If your database is very large you might need to backup directly from your SQL server via the command line, or have your server admin do it for you if you do not have root privileges.

    Usage Example

    -- cgit v1.2.3-24-g4f1b