使用dbForge插入查询未插入默认值

时间:2017-04-27 08:45:26

标签: php mysql codeigniter

我正在尝试将默认值插入到新创建的表中,但是创建的表没有值。如何在创建表后使用dbForge插入值?

我的控制器代码如下:

    $fields = array('id' => 
                    array('type' => 'INT','constraint' => 11,
                    'unsigned' => TRUE,'auto_increment' => TRUE),
                    'home_bg' => array('type' => 'VARCHAR','constraint' => '200',),
                    'login_bg' => array('type' => 'VARCHAR','constraint' => '200',),
                    'other_bg' => array('type' =>'VARCHAR','constraint' => '200',),
                    'uploaded_on' => array('type' => 'DATE',),);
    $this->dbforge->add_field($fields);
    $this->dbforge->add_key('id', TRUE);
    $this->dbforge->create_table('pr_backgrounds', TRUE);

1 个答案:

答案 0 :(得分:0)

试试这个

     $fields = array(
                            'id' => array(
                                             'type' => 'INT',
                                             'constraint' => 11,
                                             'unsigned' => TRUE,
                                             'auto_increment' => TRUE
                                         ),
                            'home_bg' => array(
                                                     'type' => 'VARCHAR',
                                                     'constraint' => '200',
                                              ),
                            'other_bg' => array(
                                                     'type' =>'VARCHAR',
                                                     'constraint' => '200',
                                              ),
                            'uploaded_on' => array(
                                                     'type' => 'DATE'
                                              ),
                    );

        $this->dbforge->add_field($fields);
        $this->dbforge->add_key('id', TRUE);
        $this->dbforge->create_table('ipn_log', TRUE);