我正在尝试使以下内容正常工作。我的 else 工作正常,但我在 if 部分遇到了问题。它所做的是删除该行并将 0 插入该hottest_cat
行。它应该从 插入值$dd
。关于我做错了什么的任何想法?
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));
}
}