Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/232.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/71.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 代码点火器计数\u所有\u结果与联接表_Php_Mysql_Codeigniter - Fatal编程技术网

Php 代码点火器计数\u所有\u结果与联接表

Php 代码点火器计数\u所有\u结果与联接表,php,mysql,codeigniter,Php,Mysql,Codeigniter,我无法从表中获取行数 下面是我使用CodeIgniter进行的mysql查询: $this->db->where('rd', 1); $this->db->where('id_user_first', $user_type); $this->db->from("messaging"); $this->db->join('answers', "answers.id_message = messaging.id AND answers.id_user

我无法从表中获取行数

下面是我使用CodeIgniter进行的mysql查询:

$this->db->where('rd', 1);
$this->db->where('id_user_first', $user_type);
$this->db->from("messaging");
$this->db->join('answers', "answers.id_message = messaging.id AND answers.id_user != '$user_type'");
$count_reponse  = $this->db->count_all_results();
我收到以下错误消息:

分析错误:语法错误,意外的“” (T_常量_封装的_字符串),应为“,”或“;”在


您可以针对您的问题尝试以下解决方案:

请更改查询

$this->db->select('messaging.*,answers.*);
$this->db->from(“消息传递”);
$this->db->join('answers',“answers.id_message=messaging.id”);
$this->db->where('answers.id\u user',$user\u type);
$this->db->where('messaging.rd',1);
$this->db->where('messaging.id\u user\u first',$user\u type);
$count_reponse=$this->db->count_all_results();

您可以针对您的问题尝试以下解决方案:

请更改查询

$this->db->select('messaging.*,answers.*);
$this->db->from(“消息传递”);
$this->db->join('answers',“answers.id_message=messaging.id”);
$this->db->where('answers.id\u user',$user\u type);
$this->db->where('messaging.rd',1);
$this->db->where('messaging.id\u user\u first',$user\u type);
$count_reponse=$this->db->count_all_results();

您需要转义引号或将内部双引号更改为单引号

$this->db->join('answers', 'answers.id_message = messaging.id AND answers.id_user != '.$user_type.'','left');
请尝试以下查询:

$this->db->where('rd', 1);
$this->db->where('id_user_first', $user_type);
$this->db->from("messaging");       
$this->db->join('answers', 'answers.id_message = messaging.id', 'left');        
$this->db->where('answers.id_user !=', $user_type);
$count_reponse  = $this->db->count_all_results();

我希望这会有帮助。如果出现任何错误,请留下评论。

您需要转义引号或将内部双引号更改为单引号

$this->db->join('answers', 'answers.id_message = messaging.id AND answers.id_user != '.$user_type.'','left');
请尝试以下查询:

$this->db->where('rd', 1);
$this->db->where('id_user_first', $user_type);
$this->db->from("messaging");       
$this->db->join('answers', 'answers.id_message = messaging.id', 'left');        
$this->db->where('answers.id_user !=', $user_type);
$count_reponse  = $this->db->count_all_results();

我希望这会有帮助。如果出现任何错误,请留下评论。

$user\u type
此变量中包含什么值?我建议从$user中删除“”_type@PankajMakwana是任何用户的INT值。@RahulMeshram问题不在那里,先生,我更喜欢使用它们,尤其是用于长值或加密的条目。
$user\u type
此变量中包含什么值?我建议从$user中删除“”_type@PankajMakwana是任何用户的INT值。@RahulMeshram问题不在那里,先生,我更喜欢使用它们,尤其是用于长值或加密条目。感谢您的努力,但仍然会收到完全相同的错误消息。请发布新的错误消息,并请立即检查新的答案。问题已解决,谢谢先生。感谢您的努力,但仍然收到完全相同的错误消息。请发布新的错误消息,并请立即检查新的答案。问题已解决,谢谢先生。