有人可以幫我添加外鍵和在Codeigniter遷移數據庫中嗎? 這是代碼:在Codeigniter遷移中添加外鍵
public function up()
{
$this->dbforge->add_field(array(
'ID_PELAYANAN' => array(
'type' => 'INT',
'constraint' => 50,
'auto_increment' => TRUE
),
'THBLMUT' => array(
'type' => 'VARCHAR',
'constraint' => '6',
),
'ID_DIST' => array(
'type' => 'VARCHAR',
'constraint' => '2',
),
'ID_AREA' => array(
'type' => 'VARCHAR',
'constraint' => '5',
),
'ID_RAYON' => array(
'type' => 'VARCHAR',
'constraint' => '5',
),
'N_RAYON' => array(
'type' => 'CHAR',
'constraint' => '70',
),
));
$this->dbforge->add_key('ID_PELAYANAN', TRUE);
$this->dbforge->create_table('pelayanan');
}
public function down()
{
$this->dbforge->drop_table('pelayanan');
}
}
我要讓 'ID_AREA', 'ID_RAYON' 作爲Forein鍵在此表中。我該如何解決這個問題?