Php 浏览器中是否有更简单的快捷方式替换我的模型SQL语法错误
型号:Php 浏览器中是否有更简单的快捷方式替换我的模型SQL语法错误,php,mysql,codeigniter,Php,Mysql,Codeigniter,型号: function getUserDetail($user_id) { $this->db->select('*'); $this->db->from('tbl_loggedin_user'); $this->db->where('user_id =',$user_id); return $this->db->get()->result_array(); } 浏览器中出现如下错误: 错误号码:
function getUserDetail($user_id)
{
$this->db->select('*');
$this->db->from('tbl_loggedin_user');
$this->db->where('user_id =',$user_id);
return $this->db->get()->result_array();
}
浏览器中出现如下错误:
错误号码:1064
SELECT * FROM (`tbl_loggedin_user`) WHERE `user_id` =
问题概述
我的CodeIgniter站点停止维护后,我需要一种方法来绕过模型文件中的SQL语法错误。我已经尽我所能找到了解决办法。寻找任何相关的代码场景,可以附加到缓解浏览器错误的解决方案中。关于如何用好代码替换坏代码,我现在需要一些建议。根据,您的查询应该是这样的:
function getUserDetail($user_id)
{
$this->db->select('*');
$this->db->from('tbl_loggedin_user');
$this->db->where('user_id', $user_id);
return $this->db->get()->result_array();
}
最少的代码答案是
function getUserDetail($user_id)
{
return $this->db
->get_where('tbl_loggedin_user', ['user_id' => $user_id])
->result_array();
}
非常感谢,简明扼要。Stackoverflow又这么做了!