From 928c55cbc5f3f162c10077f46d75d0bc0b1cbe53 Mon Sep 17 00:00:00 2001 From: Derek Allard Date: Thu, 21 Aug 2008 12:46:58 +0000 Subject: further whitespace fixes --- user_guide/database/active_record.html | 74 +++++++++++++++++----------------- user_guide/database/forge.html | 62 ++++++++++++++-------------- user_guide/database/index.html | 2 +- 3 files changed, 69 insertions(+), 69 deletions(-) (limited to 'user_guide/database') diff --git a/user_guide/database/active_record.html b/user_guide/database/active_record.html index afdc9b5ef..f3bde15e4 100644 --- a/user_guide/database/active_record.html +++ b/user_guide/database/active_record.html @@ -129,8 +129,8 @@ $query = $this->db->get('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 *

$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);
- $query = $this->db->get('mytable');
+

$this->db->select('(SELECT SUM(payments.amount) FROM payments WHERE payments.invoice_id=4') AS amount_paid', FALSE);
+$query = $this->db->get('mytable');

$this->db->select_max();

Writes a "SELECT MAX(field)" portion for your query. You can optionally include a second parameter to rename the resulting field.

@@ -280,30 +280,30 @@ $this->db->or_where('id >', $id);

$this->db->where_in();

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);
- // Produces: WHERE username IN ('Frank', 'Todd', 'James')

+ $names = array('Frank', 'Todd', 'James');
+ $this->db->where_in('username', $names);
+ // Produces: WHERE username IN ('Frank', 'Todd', 'James')

$this->db->or_where_in();

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

- $names = array('Frank', 'Todd', 'James');
- $this->db->or_where_in('username', $names);
- // Produces: OR username IN ('Frank', 'Todd', 'James')

- + $names = array('Frank', 'Todd', 'James');
+ $this->db->or_where_in('username', $names);
+ // Produces: OR username IN ('Frank', 'Todd', 'James')

+

$this->db->where_not_in();

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

- $names = array('Frank', 'Todd', 'James');
- $this->db->where_not_in('username', $names);
- // Produces: WHERE username NOT IN ('Frank', 'Todd', 'James')

+ $names = array('Frank', 'Todd', 'James');
+ $this->db->where_not_in('username', $names);
+ // Produces: WHERE username NOT IN ('Frank', 'Todd', 'James')

$this->db->or_where_not_in();

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

- $names = array('Frank', 'Todd', 'James');
- $this->db->or_where_not_in('username', $names);
- // Produces: OR username NOT IN ('Frank', 'Todd', 'James')

+ $names = array('Frank', 'Todd', 'James');
+ $this->db->or_where_not_in('username', $names);
+ // Produces: OR username NOT IN ('Frank', 'Todd', 'James')

$this->db->like();

This function enables you to generate LIKE clauses, useful for doing searches.

@@ -327,7 +327,7 @@ $this->db->or_where('id >', $id); $this->db->like('title', 'match', 'before');
// Produces: WHERE title LIKE '%match'
-
+
$this->db->like('title', 'match', 'after');
// Produces: WHERE title LIKE 'match%'

@@ -341,7 +341,7 @@ $this->db->or_where('id >', $id); $this->db->like($array);

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

$this->db->or_like();

@@ -387,9 +387,9 @@ $this->db->or_not_like('body', 'match');

Adds the "DISTINCT" keyword to a query

$this->db->distinct();
- $this->db->get('table');
-
- // Produces: SELECT DISTINCT * FROM table

+ $this->db->get('table');
+
+ // Produces: SELECT DISTINCT * FROM table

$this->db->having();

Permits you to write the HAVING portion of your query. There are 2 possible syntaxe, 1 argument or 2:

@@ -435,10 +435,10 @@ The second parameter lets you set the direction of the result. Options are Or multiple function calls can be made if you need multiple fields.

$this->db->order_by("title", "desc");
- $this->db->order_by("name", "asc");
-
- // Produces: ORDER BY title DESC, name ASC -

+ $this->db->order_by("name", "asc");
+
+ // Produces: ORDER BY title DESC, name ASC +

Note: order_by() was formerly known as orderby(), which has been deprecated.

Note: random ordering is not currently supported in Oracle or MSSQL drivers. These will default to 'ASC'.

$this->db->limit();

@@ -543,12 +543,12 @@ $this->db->set('status', $status);
$this->db->insert('mytable');

set() will also accept an optional third parameter ($escape), that will prevent data from being escaped if set to FALSE. To illustrate the difference, here is set() used both with and without the escape parameter.

$this->db->set('field', 'field+1', FALSE);
- $this->db->insert('mytable');
- // gives INSERT INTO mytable (field) VALUES (field+1)
-
- $this->db->set('field', 'field+1');
- $this->db->insert('mytable');
- // gives INSERT INTO mytable (field) VALUES ('field+1')

+ $this->db->insert('mytable');
+ // gives INSERT INTO mytable (field) VALUES (field+1)
+
+ $this->db->set('field', 'field+1');
+ $this->db->insert('mytable');
+ // gives INSERT INTO mytable (field) VALUES ('field+1')

You can also pass an associative array to this function:

$array = array('name' => $name, 'title' => $title, 'status' => $status);

@@ -657,19 +657,19 @@ $this->db->delete('mytable', array('id' => $id)); the data to the second parameter of the function:

$this->db->where('id', $id);
- $this->db->delete('mytable');
-
- // Produces:
- // DELETE FROM mytable
- // WHERE id = $id

+ $this->db->delete('mytable');
+
+ // Produces:
+ // DELETE FROM mytable
+ // WHERE id = $id

An array of table names can be passed into delete() if you would like to delete data from more then 1 table.

$tables = array('table1', 'table2', 'table3');
$this->db->where('id', '5');
$this->db->delete($tables);

If you want to delete all data from a table, you can use the truncate() function, or empty_table().

$this->db->empty_table();

-

Generates a delete SQL string and runs the query. $this->db->empty_table('mytable');
-
+

Generates a delete SQL string and runs the query. $this->db->empty_table('mytable');
+
// Produces
// DELETE FROM mytable

$this->db->truncate();

diff --git a/user_guide/database/forge.html b/user_guide/database/forge.html index 12ac62f57..bc67436bb 100644 --- a/user_guide/database/forge.html +++ b/user_guide/database/forge.html @@ -116,27 +116,27 @@ already be running, since the forge class relies on it.

Fields are created via an associative array. Within the array you must include a 'type' key that relates to the datatype of the field. For example, INT, VARCHAR, TEXT, etc. Many datatypes (for example VARCHAR) also require a 'constraint' key.

$fields = array(
                        'users' => array(
-                                                  'type' => 'VARCHAR',
-                                                  'constraint' => '100',
-                                           ),
-                 );
-
+                                                  'type' => 'VARCHAR',
+                                                  'constraint' => '100',
+                                           ),
+                 );
+
// will translate to "users VARCHAR(100)" when the field is added.

Additionally, the following key/values can be used:

    -
  • unsigned/true : to generate "UNSIGNED" in the field definition.
  • -
  • default/value : to generate a default value in the field definition.
  • -
  • null/true : to generate "NULL" in the field definition. Without this, the field will default to "NOT NULL".
  • -
  • auto_increment/true : generates an auto_increment flag on the field. Note that the field type must be a type that supports this, such as integer.
  • -
+
  • unsigned/true : to generate "UNSIGNED" in the field definition.
  • +
  • default/value : to generate a default value in the field definition.
  • +
  • null/true : to generate "NULL" in the field definition. Without this, the field will default to "NOT NULL".
  • +
  • auto_increment/true : generates an auto_increment flag on the field. Note that the field type must be a type that supports this, such as integer.
  • +

    $fields = array(
    -                         'blog_id' => array(
    -                                                  'type' => 'INT',
    -                                                  'constraint' => 5,
    -                                                  'unsigned' => TRUE,
    -                                                  'auto_increment' => TRUE
    -                                           ),
    -                         'blog_title' => array(
    +                         'blog_id' => array(
    +                                                  'type' => 'INT',
    +                                                  'constraint' => 5,
    +                                                  'unsigned' => TRUE,
    +                                                  'auto_increment' => TRUE
    +                                           ),
    +                         'blog_title' => array(
                                                     'type' => 'VARCHAR',
                                                     'constraint' => '100',
                                              ),
    @@ -161,22 +161,22 @@ already be running, since the forge class relies on it.

    Creating an id field

    There is a special exception for creating id fields. A field with type id will automatically be assinged as an INT(9) auto_incrementing Primary Key.

    $this->dbforge->add_field('id');
    - // gives id INT(9) NOT NULL AUTO_INCREMENT

    + // gives id INT(9) NOT NULL AUTO_INCREMENT

    Adding Keys

    Generally speaking, you'll want your table to have Keys. This is accomplished with $this->dbforge->add_key('field'). An optional second parameter set to TRUE will make it a primary key. Note that add_key() must be followed by a call to create_table().

    Multiple column non-primary keys must be sent as an array. Sample output below is for MySQL.

    $this->dbforge->add_key('blog_id', TRUE);
    - // gives PRIMARY KEY `blog_id` (`blog_id`)
    -
    - $this->dbforge->add_key('blog_id', TRUE);
    - $this->dbforge->add_key('site_id', TRUE);
    - // gives PRIMARY KEY `blog_id_site_id` (`blog_id`, `site_id`)
    + // gives PRIMARY KEY `blog_id` (`blog_id`)
    +
    + $this->dbforge->add_key('blog_id', TRUE);
    + $this->dbforge->add_key('site_id', TRUE);
    + // gives PRIMARY KEY `blog_id_site_id` (`blog_id`, `site_id`)

    - $this->dbforge->add_key('blog_name');
    - // gives KEY `blog_name` (`blog_name`)
    -
    - $this->dbforge->add_key(array('blog_name', 'blog_label'));
    - // gives KEY `blog_name_blog_label` (`blog_name`, `blog_label`)

    + $this->dbforge->add_key('blog_name');
    + // gives KEY `blog_name` (`blog_name`)
    +
    + $this->dbforge->add_key(array('blog_name', 'blog_label'));
    + // gives KEY `blog_name_blog_label` (`blog_name`, `blog_label`)

    Creating a table

    After fields and keys have been declared, you can create a new table with

    $this->dbforge->create_table('table_name');
    @@ -196,7 +196,7 @@ already be running, since the forge class relies on it.

    $this->dbforge->add_column()

    The add_column() function is used to modify an existing table. It accepts the same field array as above, and can be used for an unlimited number of additional fields.

    $fields = array(
    -                         'preferences' => array('type' => 'TEXT')
    +                         'preferences' => array('type' => 'TEXT')
    );
    $this->dbforge->add_column('table_name', $fields);

    @@ -213,8 +213,8 @@ $this->dbforge->add_column('table_name', $fields);
                                                    ),
    );
    $this->dbforge->modify_column('table_name', $fields);
    -
    - // gives ALTER TABLE table_name CHANGE old_name new_name TEXT

    +
    + // gives ALTER TABLE table_name CHANGE old_name new_name TEXT

     

    diff --git a/user_guide/database/index.html b/user_guide/database/index.html index a6854b5bb..5dcea988a 100644 --- a/user_guide/database/index.html +++ b/user_guide/database/index.html @@ -76,7 +76,7 @@ structures and Active Record patterns. The database functions offer clear, simpl
  • Custom Function Calls
  • Query Caching
  • Database manipulation with Database Forge
  • -
  • Database Utilities Class
  • +
  • Database Utilities Class
  • -- cgit v1.2.3-24-g4f1b