0
我想添加一些字段到我的表的列。當我檢查我的表時,我發現可以創建該列,但無法添加字段。但是,我沒有任何錯誤或任何東西。爲什麼我的字段沒有被添加到數據庫中?
public function isset_row($target, $sender_table, $receiver_table, $sender_row) {
$this->load->model('Connection_model');
if ($this->Connection_model->get_custom_db($target)->get($sender_table)) {
// Add column(s)
$this->myforge = $this->load->dbforge($this->Connection_model->get_custom_db('receiver'), TRUE);
$fields = array(
$sender_row => array('type' => 'TEXT')
);
$this->myforge->add_column($receiver_table, $fields);
$query = $this->Connection_model->get_custom_db('sender')->get($sender_table);
foreach ($query->result() as $row) {
echo $row->$sender_row . '<br>'; // Returns fields from a table (string)
echo $receiver_table; // Returns table name (string)
$this->Connection_model->get_custom_db('receiver')->update($receiver_table, $row->$sender_row);
}
}
}
EDIT1:
var_dump($this->Connection_model->get_custom_db('receiver')->update($receiver_table, $row->$sender_row));
此行返回布爾(假)
EDIT2:
隨着我只是說給字段添加到update()函數表格,但我不是說表格的哪一欄。我認爲這必須是關鍵,但如何在嘗試更新時指定列?
你是什麼意思添加字段?你的意思是你插入(或更新)一些數據到表中? – 2015-04-05 23:32:05
@ShaifulIslam是的,正好。 – 2015-04-05 23:35:14
請參閱https://ellislab.com/codeigniter/user-guide/database/active_record.html#update – 2015-04-05 23:40:18