From 0e3263b44d2762894588ff3e682579ec0cb77fa0 Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Thu, 10 Mar 2011 16:37:35 +0000 Subject: Updated version number in User Guide html. --- user_guide/database/active_record.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'user_guide/database/active_record.html') diff --git a/user_guide/database/active_record.html b/user_guide/database/active_record.html index f2f33e212..812deb90c 100644 --- a/user_guide/database/active_record.html +++ b/user_guide/database/active_record.html @@ -27,7 +27,7 @@
- +

CodeIgniter User Guide Version 2.0.0

CodeIgniter User Guide Version 2.0.1

-- cgit v1.2.3-24-g4f1b From 74089b2e80614f65112d812470b0959909e37682 Mon Sep 17 00:00:00 2001 From: Eric Barnes Date: Mon, 21 Mar 2011 21:03:04 -0400 Subject: Fixed wording when inserting object via active record. Fixes: #143 --- user_guide/database/active_record.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'user_guide/database/active_record.html') diff --git a/user_guide/database/active_record.html b/user_guide/database/active_record.html index 812deb90c..dc06c87be 100644 --- a/user_guide/database/active_record.html +++ b/user_guide/database/active_record.html @@ -517,7 +517,7 @@ $this->db->insert('mytable', $object);

// Produces: INSERT INTO mytable (title, content, date) VALUES ('My Title', 'My Content', 'My Date') -

The first parameter will contain the table name, the second is an associative array of values.

+

The first parameter will contain the table name, the second is an object.

Note: All values are escaped automatically producing safer queries.

-- cgit v1.2.3-24-g4f1b From 05fa61144667c85b0463f7e8baa6af00aa195dc6 Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Wed, 6 Apr 2011 22:57:43 +0100 Subject: Made Environment Support optional. Comment out or delete the constant to stop environment checks. --- user_guide/database/active_record.html | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'user_guide/database/active_record.html') diff --git a/user_guide/database/active_record.html b/user_guide/database/active_record.html index dc06c87be..64596e271 100644 --- a/user_guide/database/active_record.html +++ b/user_guide/database/active_record.html @@ -545,6 +545,30 @@ $this->db->insert_batch('mytable', $data);

The first parameter will contain the table name, the second is an associative array of values.

+

$this->db->insert_batch();

+

Generates an insert string based on the data you supply, and runs the query. You can either pass an +array or an object to the function. Here is an example using an array:

+ + +$data = array(
+   array(
+      'title' => 'My title' ,
+      'name' => 'My Name' ,
+      'date' => 'My date'
+   ),
+   array(
+      'title' => 'Another title' ,
+      'name' => 'Another Name' ,
+      'date' => 'Another date'
+   )
+);
+
+$this->db->update_batch('mytable', $data); +

+// Produces: INSERT INTO mytable (title, name, date) VALUES ('My title', 'My name', 'My date'), ('Another title', 'Another name', 'Another date')
+ +

The first parameter will contain the table name, the second is an associative array of values.

+

Note: All values are escaped automatically producing safer queries.

-- cgit v1.2.3-24-g4f1b From 1f622294b92c095fd91e8ca44912d405c1605ded Mon Sep 17 00:00:00 2001 From: Pascal Kriete Date: Thu, 7 Apr 2011 12:06:51 -0400 Subject: Wow, I screwed that up, Reactor is going to 2.0.2 not 2.0.1 --- user_guide/database/active_record.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'user_guide/database/active_record.html') diff --git a/user_guide/database/active_record.html b/user_guide/database/active_record.html index 64596e271..faa13b3e7 100644 --- a/user_guide/database/active_record.html +++ b/user_guide/database/active_record.html @@ -27,7 +27,7 @@
- +

CodeIgniter User Guide Version 2.0.1

CodeIgniter User Guide Version 2.0.2

-- cgit v1.2.3-24-g4f1b From bf8d68a5652e52c39c59c7e441dcb4fe1ccd15cf Mon Sep 17 00:00:00 2001 From: Eric Barnes Date: Sun, 24 Apr 2011 20:38:17 -0400 Subject: Duplicate this->db->insert_batch in documentation. Fixes #202 --- user_guide/database/active_record.html | 24 ------------------------ 1 file changed, 24 deletions(-) (limited to 'user_guide/database/active_record.html') diff --git a/user_guide/database/active_record.html b/user_guide/database/active_record.html index faa13b3e7..62833813c 100644 --- a/user_guide/database/active_record.html +++ b/user_guide/database/active_record.html @@ -525,30 +525,6 @@ $this->db->insert('mytable', $object);

Generates an insert string based on the data you supply, and runs the query. You can either pass an array or an object to the function. Here is an example using an array:

- -$data = array(
-   array(
-      'title' => 'My title' ,
-      'name' => 'My Name' ,
-      'date' => 'My date'
-   ),
-   array(
-      'title' => 'Another title' ,
-      'name' => 'Another Name' ,
-      'date' => 'Another date'
-   )
-);
-
-$this->db->insert_batch('mytable', $data); -

-// Produces: INSERT INTO mytable (title, name, date) VALUES ('My title', 'My name', 'My date'), ('Another title', 'Another name', 'Another date')
- -

The first parameter will contain the table name, the second is an associative array of values.

- -

$this->db->insert_batch();

-

Generates an insert string based on the data you supply, and runs the query. You can either pass an -array or an object to the function. Here is an example using an array:

- $data = array(
   array(
-- cgit v1.2.3-24-g4f1b From 114ab0988e20ac6be39ad363ff897a1a3b85e565 Mon Sep 17 00:00:00 2001 From: Razican Date: Mon, 25 Apr 2011 17:26:45 +0200 Subject: Fixed double-space typo. --- user_guide/database/active_record.html | 68 +++++++++++++++++----------------- 1 file changed, 34 insertions(+), 34 deletions(-) (limited to 'user_guide/database/active_record.html') diff --git a/user_guide/database/active_record.html b/user_guide/database/active_record.html index 62833813c..566b260c9 100644 --- a/user_guide/database/active_record.html +++ b/user_guide/database/active_record.html @@ -59,12 +59,12 @@ Active Record

CodeIgniter 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. -CodeIgniter does not require that each database table be its own class file. It instead provides a more simplified interface.

+CodeIgniter 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 -is generated by each database adapter. It also allows for safer queries, since the values are escaped automatically by the system.

+is generated by each database adapter. It also allows for safer queries, since the values are escaped automatically by the system.

-

Note: If you intend to write your own queries you can disable this class in your database config file, allowing the core database library and adapter to utilize fewer resources.

+

Note: If you intend to write your own queries you can disable this class in your database config file, allowing the core database library and adapter to utilize fewer resources.

  • Selecting Data
  • @@ -84,7 +84,7 @@ is generated by each database adapter. It also allows for safer queries, since

    $this->db->get();

    -

    Runs the selection query and returns the result. Can be used by itself to retrieve all records from a table:

    +

    Runs the selection query and returns the result. Can be used by itself to retrieve all records from a table:

    $query = $this->db->get('mytable');

    @@ -126,7 +126,7 @@ $this->db->select('title, content, date');
    $query = $this->db->get('mytable');

    // Produces: SELECT title, content, date FROM mytable

    -

    Note: If you are selecting all (*) from a table you do not need to use this function. When omitted, CodeIgniter assumes you wish to SELECT *

    +

    Note: If you are selecting all (*) from a table you do not need to use this function. When omitted, CodeIgniter assumes you wish to SELECT *

    $this->db->select() accepts an optional second parameter. If you set it to FALSE, CodeIgniter will not try to protect your field or table names with backticks. This is useful if you need a compound select statement.

    $this->db->select('(SELECT SUM(payments.amount) FROM payments WHERE payments.invoice_id=4') AS amount_paid', FALSE);
    @@ -278,7 +278,7 @@ $this->db->or_where('id >', $id);

    $this->db->where_in();

    -

    Generates a WHERE field IN ('item', 'item') SQL query joined with AND if appropriate

    +

    Generates a WHERE field IN ('item', 'item') SQL query joined with AND if appropriate

    $names = array('Frank', 'Todd', 'James');
    $this->db->where_in('username', $names);
    @@ -322,7 +322,7 @@ $this->db->or_where('id >', $id); $this->db->like('title', 'match');
    $this->db->like('body', 'match');

    - // WHERE title LIKE '%match%' AND body LIKE '%match%
    + // WHERE title LIKE '%match%' AND body LIKE '%match%
    If you want to control where the wildcard (%) is placed, you can use an optional third argument. Your options are 'before', 'after' and 'both' (which is the default). $this->db->like('title', 'match', 'before');
    @@ -340,7 +340,7 @@ $this->db->or_where('id >', $id); $array = array('title' => $match, 'page1' => $match, 'page2' => $match);

    $this->db->like($array); -

    // WHERE title LIKE '%match%' AND page1 LIKE '%match%' AND page2 LIKE '%match%'
    +

    // WHERE title LIKE '%match%' AND page1 LIKE '%match%' AND page2 LIKE '%match%'
    @@ -351,7 +351,7 @@ $this->db->or_where('id >', $id); $this->db->like('title', 'match');
    $this->db->or_like('body', $match);
    -
    // WHERE title LIKE '%match%' OR body LIKE '%match%' +
    // WHERE title LIKE '%match%' OR body LIKE '%match%' @@ -367,7 +367,7 @@ $this->db->or_like('body', $match); $this->db->like('title', 'match');
    $this->db->or_not_like('body', 'match');

    -// WHERE title LIKE '%match% OR body NOT LIKE '%match%'
    +// WHERE title LIKE '%match% OR body NOT LIKE '%match%'

    $this->db->group_by();

    Permits you to write the GROUP BY portion of your query:

    @@ -385,7 +385,7 @@ $this->db->or_not_like('body', 'match');

    $this->db->distinct();

    -

    Adds the "DISTINCT" keyword to a query

    +

    Adds the "DISTINCT" keyword to a query

    $this->db->distinct();
    $this->db->get('table');

    @@ -397,7 +397,7 @@ $this->db->or_not_like('body', 'match');

    // Produces: HAVING user_id = 45

    -$this->db->having('user_id', 45);
    +$this->db->having('user_id', 45);
    // Produces: HAVING user_id = 45

    @@ -409,16 +409,16 @@ $this->db->having('user_id', 45);

    // Produces: HAVING title = 'My Title', id < 45

    If you are using a database that CodeIgniter escapes queries for, you can prevent escaping content by passing an optional third argument, and setting it to FALSE.

    -

    $this->db->having('user_id', 45);
    +

    $this->db->having('user_id', 45);
    // Produces: HAVING `user_id` = 45 in some databases such as MySQL
    - $this->db->having('user_id', 45, FALSE);
    + $this->db->having('user_id', 45, FALSE);
    // Produces: HAVING user_id = 45

    $this->db->or_having();

    Identical to having(), only separates multiple clauses with "OR".

    $this->db->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 random.

    +The second parameter lets you set the direction of the result. Options are asc or desc, or random.

    $this->db->order_by("title", "desc");
    @@ -455,12 +455,12 @@ $this->db->limit(10);
    $this->db->limit(10, 20);

    -// Produces: LIMIT 20, 10 (in MySQL. Other databases have slightly different syntax)
    +// Produces: LIMIT 20, 10 (in MySQL. Other databases have slightly different syntax)

    $this->db->count_all_results();

    -

    Permits you to determine the number of rows in a particular Active Record query. Queries will accept Active Record restrictors such as where(), or_where(), like(), or_like(), etc. Example:

    +

    Permits you to determine the number of rows in a particular Active Record query. Queries will accept Active Record restrictors such as where(), or_where(), like(), or_like(), etc. Example:

    echo $this->db->count_all_results('my_table');
    // Produces an integer, like 25
    @@ -472,7 +472,7 @@ echo $this->db->count_all_results();

    $this->db->count_all();

    -

    Permits you to determine the number of rows in a particular table. Submit the table name in the first parameter. Example:

    +

    Permits you to determine the number of rows in a particular table. Submit the table name in the first parameter. Example:

    echo $this->db->count_all('my_table');

    @@ -485,7 +485,7 @@ echo $this->db->count_all_results();

    $this->db->insert();

    Generates an insert string based on the data you supply, and runs the query. You can either pass an -array or an object to the function. Here is an example using an array:

    +array or an object to the function. Here is an example using an array:

    $data = array(
    @@ -505,9 +505,9 @@ $this->db->insert('mytable', $data); /*
        class Myclass {
    -        var $title = 'My Title';
    -        var $content = 'My Content';
    -        var $date = 'My Date';
    +        var $title = 'My Title';
    +        var $content = 'My Content';
    +        var $date = 'My Date';
        }
    */

    @@ -523,7 +523,7 @@ $this->db->insert('mytable', $object);

    $this->db->insert_batch();

    Generates an insert string based on the data you supply, and runs the query. You can either pass an -array or an object to the function. Here is an example using an array:

    +array or an object to the function. Here is an example using an array:

    $data = array(
    @@ -541,7 +541,7 @@ $data = array(

    $this->db->update_batch('mytable', $data);

    -// Produces: INSERT INTO mytable (title, name, date) VALUES ('My title', 'My name', 'My date'), ('Another title', 'Another name', 'Another date')
    +// Produces: INSERT INTO mytable (title, name, date) VALUES ('My title', 'My name', 'My date'), ('Another title', 'Another name', 'Another date')

    The first parameter will contain the table name, the second is an associative array of values.

    @@ -588,9 +588,9 @@ $this->db->insert('mytable'); /*
        class Myclass {
    -        var $title = 'My Title';
    -        var $content = 'My Content';
    -        var $date = 'My Date';
    +        var $title = 'My Title';
    +        var $content = 'My Content';
    +        var $date = 'My Date';
        }
    */

    @@ -606,7 +606,7 @@ $this->db->insert('mytable');

    Updating Data

    $this->db->update();

    -

    Generates an update string and runs the query based on the data you supply. You can pass an +

    Generates an update string and runs the query based on the data you supply. You can pass an array or an object to the function. Here is an example using an array:

    @@ -630,9 +630,9 @@ $this->db->update('mytable', $data); /*
        class Myclass {
    -        var $title = 'My Title';
    -        var $content = 'My Content';
    -        var $date = 'My Date';
    +        var $title = 'My Title';
    +        var $content = 'My Content';
    +        var $date = 'My Date';
        }
    */

    @@ -711,7 +711,7 @@ $this->db->truncate('mytable');

     Method Chaining

    -

    Method chaining allows you to simplify your syntax by connecting multiple functions. Consider this example:

    +

    Method chaining allows you to simplify your syntax by connecting multiple functions. Consider this example:

    $this->db->select('title')->from('mytable')->where('id', $id)->limit(10, 20);
    @@ -752,14 +752,14 @@ $this->db->get('tablename');
    $this->db->select('field2');
    $this->db->get('tablename');

    -//Generates: SELECT `field1`, `field2` FROM (`tablename`)
    +//Generates: SELECT `field1`, `field2` FROM (`tablename`)

    $this->db->flush_cache();

    $this->db->select('field2');
    $this->db->get('tablename');

    -//Generates: SELECT `field2` FROM (`tablename`)

    +//Generates: SELECT `field2` FROM (`tablename`)

    Note: The following statements can be cached: select, from, join, where, like, group_by, having, order_by, set

     

    -- cgit v1.2.3-24-g4f1b