2017-04-27 108 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);