diff options
author | Derek Allard <derek.allard@ellislab.com> | 2008-08-21 14:46:58 +0200 |
---|---|---|
committer | Derek Allard <derek.allard@ellislab.com> | 2008-08-21 14:46:58 +0200 |
commit | 928c55cbc5f3f162c10077f46d75d0bc0b1cbe53 (patch) | |
tree | 22b9ca71872be54736e400de93cb7223cbe5ca1d /user_guide/database/forge.html | |
parent | 993925b47a0bfb08e79961c47bcc3d247a03a5dd (diff) |
further whitespace fixes
Diffstat (limited to 'user_guide/database/forge.html')
-rw-r--r-- | user_guide/database/forge.html | 62 |
1 files changed, 31 insertions, 31 deletions
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.</p> <p>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.</p>
<p><code>$fields = array(<br />
'users' => array(<br />
- 'type' => 'VARCHAR',<br />
- 'constraint' => '100',<br />
- ),<br />
- );<br />
- <br />
+ 'type' => 'VARCHAR',<br />
+ 'constraint' => '100',<br />
+ ),<br />
+ );<br />
+ <br />
// will translate to "users VARCHAR(100)" when the field is added.</code></p>
<p>Additionally, the following key/values can be used:</p>
<ul>
- <li>unsigned/true : to generate "UNSIGNED" in the field definition.</li>
- <li>default/value : to generate a default value in the field definition.</li>
- <li>null/true : to generate "NULL" in the field definition. Without this, the field will default to "NOT NULL".</li>
- <li>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.</li>
- </ul>
+ <li>unsigned/true : to generate "UNSIGNED" in the field definition.</li>
+ <li>default/value : to generate a default value in the field definition.</li>
+ <li>null/true : to generate "NULL" in the field definition. Without this, the field will default to "NOT NULL".</li>
+ <li>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.</li>
+ </ul>
<p><code>$fields = array(<br />
- 'blog_id' => array(<br />
- 'type' => 'INT',<br />
- 'constraint' => 5, <br />
- 'unsigned' => TRUE,<br />
- 'auto_increment' => TRUE<br />
- ),<br />
- 'blog_title' => array(<br />
+ 'blog_id' => array(<br />
+ 'type' => 'INT',<br />
+ 'constraint' => 5, <br />
+ 'unsigned' => TRUE,<br />
+ 'auto_increment' => TRUE<br />
+ ),<br />
+ 'blog_title' => array(<br />
'type' => 'VARCHAR',<br />
'constraint' => '100',<br />
),<br />
@@ -161,22 +161,22 @@ already be running, since the forge class relies on it.</p> <h3>Creating an id field</h3>
<p>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.</p>
<p><code>$this->dbforge->add_field('id');<br />
- // gives id INT(9) NOT NULL AUTO_INCREMENT</code></p>
+ // gives id INT(9) NOT NULL AUTO_INCREMENT</code></p>
<h2><a name="add_key" id="add_key"></a>Adding Keys</h2>
<p>Generally speaking, you'll want your table to have Keys. This is accomplished with <dfn>$this->dbforge->add_key('field')</dfn>. An optional second parameter set to TRUE will make it a primary key. Note that <dfn>add_key()</dfn> must be followed by a call to <dfn>create_table()</dfn>.</p>
<p>Multiple column non-primary keys must be sent as an array. Sample output below is for MySQL.</p>
<p><code>$this->dbforge->add_key('blog_id', TRUE);<br />
- // gives PRIMARY KEY `blog_id` (`blog_id`)<br />
- <br />
- $this->dbforge->add_key('blog_id', TRUE);<br />
- $this->dbforge->add_key('site_id', TRUE);<br />
- // gives PRIMARY KEY `blog_id_site_id` (`blog_id`, `site_id`)<br />
+ // gives PRIMARY KEY `blog_id` (`blog_id`)<br />
+ <br />
+ $this->dbforge->add_key('blog_id', TRUE);<br />
+ $this->dbforge->add_key('site_id', TRUE);<br />
+ // gives PRIMARY KEY `blog_id_site_id` (`blog_id`, `site_id`)<br />
<br />
- $this->dbforge->add_key('blog_name');<br />
- // gives KEY `blog_name` (`blog_name`)<br />
- <br />
- $this->dbforge->add_key(array('blog_name', 'blog_label'));<br />
- // gives KEY `blog_name_blog_label` (`blog_name`, `blog_label`)</code></p>
+ $this->dbforge->add_key('blog_name');<br />
+ // gives KEY `blog_name` (`blog_name`)<br />
+ <br />
+ $this->dbforge->add_key(array('blog_name', 'blog_label'));<br />
+ // gives KEY `blog_name_blog_label` (`blog_name`, `blog_label`)</code></p>
<h2><a name="create_table" id="create_table"></a>Creating a table</h2>
<p>After fields and keys have been declared, you can create a new table with</p>
<p><code>$this->dbforge->create_table('table_name');<br />
@@ -196,7 +196,7 @@ already be running, since the forge class relies on it.</p> <h2>$this->dbforge->add_column()</h2>
<p>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.</p>
<p><code>$fields = array(<br />
- 'preferences' => array('type' => 'TEXT')<br />
+ 'preferences' => array('type' => 'TEXT')<br />
);<br />
$this->dbforge->add_column('table_name', $fields);<br />
<br />
@@ -213,8 +213,8 @@ $this->dbforge->add_column('table_name', $fields);<br /> ),<br />
);<br />
$this->dbforge->modify_column('table_name', $fields);<br />
- <br />
- // gives ALTER TABLE table_name CHANGE old_name new_name TEXT </code></p>
+ <br />
+ // gives ALTER TABLE table_name CHANGE old_name new_name TEXT </code></p>
<p> </p>
</div>
<!-- END CONTENT -->
|