星期四

CodeIgniter中創建數據表

//設置字段
$fields = array(
'id' => array(
'type' => 'INT',
'constraint' => 11,
'unsigned' => TRUE,
'AUTO_INCREMENT' => TRUE
),
'userid' => array(
'type' => 'INT',
'constraint' => 11,
'unsigned' => TRUE
),
'cions' => array(
'type' => 'DECIMAL',
'constraint' => '14,4',
'unsigned' => TRUE
)
);
$this->dbforge->add_field($fields);
$this->dbforge->add_key('id');
$this->dbforge->create_table('zz_gamecion0_' . $name);

值得注意的是後面的add_key可以將前面的某個字段設置為主

没有评论:

发表评论

旋转的旧记忆