我怎樣才能讓使用Codeigniter Dbforge
遷移financial_year
字段作爲獨特之處?在笨DBForge遷移創造出獨特的領域
function up() {
$this->dbforge->add_field(array(
'id' => array(
'type' => 'INT',
'constraint' => 11,
'unsigned' => TRUE,
'auto_increment' => TRUE
),
'financial_year' => array(
'type' => 'VARCHAR',
'constraint' => 20
),
'start_date' => array(
'type' => 'DATE'
),
'end_date' => array(
'type' => 'DATE'
),
'status' => array(
'type' => "ENUM",
'constraint' => "'Active','Inactive'",
'default' => "Active"
),
'created_on' => array(
'type' => 'TIMESTAMP'
)
));
$this->dbforge->add_key('id', TRUE); // add `id` as primary key
$this->dbforge->create_table('financial_year'); // create table schema
}
它不應該是'''$這個 - > DB-> query' ''?這打破了我的移民 – sinhix
正確的 - 它應該是:'$這個 - > DB->查詢( 'ALTER TABLE financial_year ADD UNIQUE INDEX(financial_year)');' –