Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/295.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 浏览器中是否有更简单的快捷方式替换我的模型SQL语法错误_Php_Mysql_Codeigniter - Fatal编程技术网

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又这么做了!