我需要在我的身份验证脚本中设置查询,我想在 WHERE 子句中使用'_MY_POST_VALUE' IN (Field1, Field2)
最终查询将是这样的:
SELECT * FROM 'myprefix_users' WHERE 'myemail@email.com' IN ('EMAIL','LOGIN') AND PASSWORD=SHA1('mypassword')
我试过这样做:
$this->db->where("'" . mysql_escape_string($_POST['login']) . "' IN (EMAIL,LOGIN)", NULL, FALSE);
$this->db->where("PASSWORD=SHA1('" . mysql_real_escape_string($_POST['password']) . "')");
$userdb = $this->db->get('users');
..但是 CodeIgniter 将前缀设置为我的登录/电子邮件值并发送错误:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''test@test.com' IN (EMAIL,LOGIN) AND PASSWORD=SHA1('123')' at line 3
SELECT * FROM (`myprefix_users`) WHERE myprefix_'test@test.com' IN (EMAIL,LOGIN) AND PASSWORD=SHA1('123')
我需要在表名中使用 db_prefix,但我的 WHERE 子句中不需要它,即使 ->where() 中的第三个参数(FALSE)对我也不起作用:(
我该如何解决我的问题?有任何想法吗?