3
所在的位置以及条件这是我的代码:更新SQL与笨
public function remove_employee($emp_no, $now) {
$this->db->delete('employees', array('emp_no' => $emp_no));
$this->db->flush_cache();
$this->db->start_cache();
$this->db->where('emp_no', $emp_no);
$this->db->where('to_date', '9999-01-01');
$this->db->update('dept_emp', array('to_date' => $now));
$this->db->stop_cache();
$this->db->flush_cache();
$this->db->start_cache();
$this->db->where('emp_no', $emp_no);
$this->db->where('to_date', '9999-01-01');
$this->db->update('salaries', array('to_date' => $now));
$this->db->stop_cache();
$this->db->flush_cache();
$this->db->start_cache();
$this->db->where('emp_no', $emp_no);
$this->db->where('to_date', '9999-01-01');
$this->db->update('titles', array('to_date' => $now));
$this->db->stop_cache();
$this->db->flush_cache();
return;
} //END REMOVE EMPLOYEE
当我运行这段代码就删除了我的记录。我不明白为什么。
我希望它: UPDATE表WHERE CONDITION_1 和 CONDITION_2 = B
PS:
**$now** is todays date (i.e. 2012-12-25)
**$emp_no** is a unique employee number i.e. 500122
感谢您的现货。正是这些线条搞乱了它。当外键被删除时,它会删除使用该外键的所有关联记录。感谢您的帮助。 :D –
@ user1306764没问题,很高兴我可以帮忙,如果您觉得我的答案是可以接受的解决方案,请记得点击复选标记。 – PhearOfRayne