diff options
Diffstat (limited to 'user_guide/database')
-rw-r--r-- | user_guide/database/forge.html | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/user_guide/database/forge.html b/user_guide/database/forge.html index f9363f4e3..f679a4f29 100644 --- a/user_guide/database/forge.html +++ b/user_guide/database/forge.html @@ -164,11 +164,19 @@ already be running, since the forge class relies on it.</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)<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)</code></p>
+ // 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 />
|