我试图用sql为我的CI做删除选项,但为什么还有错误呢?
错误警告:
A Database Error Occurred
Error Number: 1054
Unknown column 'sip' in 'where clause'
select * from t_label where label = sip
Filename: E:\web\rbt.new\system\database\DB_driver.php
Line Number: 330
码
function hapus($id_user){
if($this->session->userdata('username')==TRUE) {
$name = $this->db->query("select USER_NAME from t_user where USER_ID = $id_user")->row();
$id_label = $this->db->query("select * from t_label where label = $name->USER_NAME")->row();
$this->db->query("delete from t_label, t_publisher where t_label.id_label = t_publisher.id_label and t_label.id_label = $id_label->id_label");
$this->db->delete('t_user', array('USER_ID' => $id_user));
redirect("registrasi/reg");
}
}
我的代码有什么问题?真的需要帮助
答案 0 :(得分:1)
你需要引用字符串。试试这个:
$id_label = $this->db->query("select * from t_label where label = '" . $name->USER_NAME . "'")->row();