douwen5833 2013-12-30 00:43
浏览 69
已采纳

codeigniter custom 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?

  • 写回答

4条回答 默认 最新

  • dou4624 2013-12-30 00:46
    关注

    use following

    $where = "user_name='$username' AND password='$password' AND (Department='$dep_br' OR Br_no='$dep_br')";
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)
编辑
预览

报告相同问题?

悬赏问题

  • ¥35 西门子博图v16安装密钥提示CryptAcquireContext MS_DEF_PROV Error of containger opening
  • ¥15 mes系统扫码追溯功能
  • ¥40 selenium访问信用中国
  • ¥20 在搭建fabric网络过程中遇到“无法使用新的生命周期”的报错
  • ¥15 Python中关于代码运行报错的问题
  • ¥500 python 的API,有酬谢
  • ¥15 软件冲突问题,软件残留问题
  • ¥30 有没有人会写hLDA,有偿求写,我有一个文档,想通过hLDA得出这个文档的层次主题,有偿有偿!
  • ¥50 有没有人会写hLDA,有偿求写,我有一个文档,想通过hLDA得出这个文档的层次主题,有偿有偿!
  • ¥15 alpha101因子里哪些适合crypto?