2017-04-27 78 views
1

我想将默认值插入到新创建的表中,但是该表创建时没有值。如何在创建表后使用dbForge插入值?使用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); 

回答

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);