From 51a4888c71287e66d21c9749c13ba895953b9acb Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Wed, 14 Sep 2011 13:47:06 -0400 Subject: Fixed affected_rows() function, added PDO/postgres note for insert_id() function --- user_guide/database/helpers.html | 1 + 1 file changed, 1 insertion(+) (limited to 'user_guide/database/helpers.html') diff --git a/user_guide/database/helpers.html b/user_guide/database/helpers.html index 6a8aba55b..ecd0d84b6 100644 --- a/user_guide/database/helpers.html +++ b/user_guide/database/helpers.html @@ -64,6 +64,7 @@ Query Helpers

$this->db->insert_id()

The insert ID number when performing database inserts.

+

Note: If using the PDO driver with PostgreSQL, this function requires a $name parameter, which specifies the appropriate sequence to check for the insert id.

$this->db->affected_rows()

Displays the number of affected rows, when doing "write" type queries (insert, update, etc.).

-- cgit v1.2.3-24-g4f1b From 57cea51f89a1da6f15d2e9e22dbd5f071b7bb286 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Wed, 14 Sep 2011 14:26:28 -0400 Subject: Miscellaneous fixes --- user_guide/database/helpers.html | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'user_guide/database/helpers.html') diff --git a/user_guide/database/helpers.html b/user_guide/database/helpers.html index ecd0d84b6..be6c339b4 100644 --- a/user_guide/database/helpers.html +++ b/user_guide/database/helpers.html @@ -68,8 +68,7 @@ Query Helpers

$this->db->affected_rows()

Displays the number of affected rows, when doing "write" type queries (insert, update, etc.).

-

Note: In MySQL "DELETE FROM TABLE" returns 0 affected rows. The database class has a small hack that allows it to return the -correct number of affected rows. By default this hack is enabled but it can be turned off in the database driver file.

+

Note: In MySQL "DELETE FROM TABLE" returns 0 affected rows. The database class has a small hack that allows it to return the correct number of affected rows. By default this hack is enabled but it can be turned off in the database driver file.

$this->db->count_all();

-- cgit v1.2.3-24-g4f1b From 8ede1a2ecbb62577afd32996956c5feaf7ddf9b6 Mon Sep 17 00:00:00 2001 From: Derek Jones Date: Wed, 5 Oct 2011 13:34:52 -0500 Subject: replacing the old HTML user guide with a Sphinx-managed user guide --- user_guide/database/helpers.html | 151 --------------------------------------- 1 file changed, 151 deletions(-) delete mode 100644 user_guide/database/helpers.html (limited to 'user_guide/database/helpers.html') diff --git a/user_guide/database/helpers.html b/user_guide/database/helpers.html deleted file mode 100644 index be6c339b4..000000000 --- a/user_guide/database/helpers.html +++ /dev/null @@ -1,151 +0,0 @@ - - - - - -Query Helper Functions : CodeIgniter User Guide - - - - - - - - - - - - - - - - - - - - - -
- - - - - -

CodeIgniter User Guide Version 2.0.3

-
- - - - - - - - - -
- - - - -
- - - -
- - -

Query Helper Functions

- - -

$this->db->insert_id()

-

The insert ID number when performing database inserts.

-

Note: If using the PDO driver with PostgreSQL, this function requires a $name parameter, which specifies the appropriate sequence to check for the insert id.

- -

$this->db->affected_rows()

-

Displays the number of affected rows, when doing "write" type queries (insert, update, etc.).

-

Note: In MySQL "DELETE FROM TABLE" returns 0 affected rows. The database class has a small hack that allows it to return the correct number of affected rows. By default this hack is enabled but it can be turned off in the database driver file.

- - -

$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:

-echo $this->db->count_all('my_table');
-
-// Produces an integer, like 25 -
- - -

$this->db->platform()

-

Outputs the database platform you are running (MySQL, MS SQL, Postgres, etc...):

-echo $this->db->platform(); - - -

$this->db->version()

-

Outputs the database version you are running:

-echo $this->db->version(); - - -

$this->db->last_query();

-

Returns the last query that was run (the query string, not the result). Example:

- -$str = $this->db->last_query();
-
-// Produces: SELECT * FROM sometable.... -
- - -

The following two functions help simplify the process of writing database INSERTs and UPDATEs.

- - -

$this->db->insert_string();

-

This function simplifies the process of writing database inserts. It returns a correctly formatted SQL insert string. Example:

- -$data = array('name' => $name, 'email' => $email, 'url' => $url);
-
-$str = $this->db->insert_string('table_name', $data); -
- -

The first parameter is the table name, the second is an associative array with the data to be inserted. The above example produces:

-INSERT INTO table_name (name, email, url) VALUES ('Rick', 'rick@example.com', 'example.com') - -

Note: Values are automatically escaped, producing safer queries.

- - - -

$this->db->update_string();

-

This function simplifies the process of writing database updates. It returns a correctly formatted SQL update string. Example:

- -$data = array('name' => $name, 'email' => $email, 'url' => $url);
-
-$where = "author_id = 1 AND status = 'active'"; -

-$str = $this->db->update_string('table_name', $data, $where); -
- -

The first parameter is the table name, the second is an associative array with the data to be updated, and the third parameter is the "where" clause. The above example produces:

- UPDATE table_name SET name = 'Rick', email = 'rick@example.com', url = 'example.com' WHERE author_id = 1 AND status = 'active' - -

Note: Values are automatically escaped, producing safer queries.

- - -
- - - - - - - \ No newline at end of file -- cgit v1.2.3-24-g4f1b