Welcome Guest, Not a member yet? Register   Sign In
dbforge add_key
#1

[eluser]Eric Barnes[/eluser]
I am trying to use the new dbforge to create a database. One issue that I can't seem to figure out is how to use the add_key to create a key on multiple fields.

Through straight mysql I am creating a table like this:
Code:
$sSQL = "CREATE TABLE `".$prefix."article2cat` (
`rel_id` bigint(20) NOT NULL auto_increment,
`article_id` bigint(20) NOT NULL default '0',
`category_id` bigint(20) NOT NULL default '0',
PRIMARY KEY  (`rel_id`),
KEY `article_id` (`article_id`,`category_id`)
);

Through dbforge I have this:
Code:
$this->dbforge->add_field($fields);
$this->dbforge->add_key('rel_id', TRUE);
$this->dbforge->add_key('article_id');
$this->dbforge->create_table('article2cat');

But I don't see a way of creating a key for two columns.
#2

[eluser]Sean Murphy[/eluser]
Does this work?
Code:
$this->dbforge->add_key('field_1, field_2');
#3

[eluser]Eric Barnes[/eluser]
That sure does and I am not sure why I didn't think about it. Smile

Thank you very much.




Theme © iAndrew 2016 - Forum software by © MyBB