0
我想讓下面的工作正常。我有其他工作正常,但我遇到了問題,如果部分。它所做的是刪除行並將0插入hottest_cat
行。它應該插入從$dd
的值。任何想法,我做錯了什麼?如果在db表中發現了某些東西,php/mysql會更新它
public function change_category() {
$dd = $this->input->post('dd');
$sql = $this->db->get('default_hottest_cat');
if ($sql->num_rows() > 0) {
$row = $sql->row();
$old = $row->hottest_cat;
// Stuff is found in this table. Needs to be deleted first, then inserted.
$this->db->delete('default_hottest_cat', array('hottest_cat' => $old));
$this->db->insert('default_hottest_cat', array('hottest_cat' => $dd));
} else {
// Nothing is found in this table. Needs only to be inserted.
$this->db->insert('default_hottest_cat', array('hottest_cat' => $dd));
}
}
爲什麼插入行註釋掉? – 2013-04-22 19:53:26
因爲我在調試它。 – 2013-04-22 19:56:07
我改變了它.... – 2013-04-22 19:56:49