Codeigniter自定义where子句中的错误 [英] error in codeigniter custom where clause
本文介绍了Codeigniter自定义where子句中的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我指的是codeigniter用户指南,用于编写自定义where子句. 按照它为自定义where子句编写的指南所述.
I'm referring the codeigniter user guide to write a custom where clause. as per the guide it says for custom where clauses write like this.
$where = "name='Joe' AND status='boss' OR status='active'";
$this->db->where($where);
但是当我在模型浏览器中使用浏览器时会抛出错误.
but when i use in my model browser is throwing an error.
A Database Error Occurred
Error Number: 1054
Unknown column 'user_name='Joe'' in 'where clause'
SELECT * FROM (`Management`) WHERE `user_name='Joe'` AND password='boss' OR password='active'
Filename: /var/www/models/hr_login_model.php
Line Number: 28
这只是一个测试查询.我的实际查询是动态查询,并且也出现此错误.
this is just a testing query. my actual query is dynamic one and it is also giving this error.
$where = "user_name='".$username."' AND password='".$password."' AND Department='".$dep_br."' OR Br_no='".$dep_br."'";
为什么总是将列名和值都作为列名?
why it always taking the column name and the value, both as a column name?
推荐答案
使用以下内容
$where = "user_name='$username' AND password='$password' AND (Department='$dep_br' OR Br_no='$dep_br')";
这篇关于Codeigniter自定义where子句中的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文