Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/70.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/5/excel/24.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 如何解决代码点火器查询中的错误1054_Php_Mysql_Codeigniter - Fatal编程技术网

Php 如何解决代码点火器查询中的错误1054

Php 如何解决代码点火器查询中的错误1054,php,mysql,codeigniter,Php,Mysql,Codeigniter,我有一个代码点火器项目托管,但我有错误号:1054 网站最受欢迎部分显示的“on子句”中的未知列“p.id” 下面是给出此错误的sql查询 public function get_popular() { // Using active records $this->db->select('P.*, COUNT(O.product_id) as total'); $this->db->from('orders AS O'); $this-&g

我有一个代码点火器项目托管,但我有错误号:1054 网站最受欢迎部分显示的“on子句”中的未知列“p.id”

下面是给出此错误的sql查询

public function get_popular()
{
    // Using active records
    $this->db->select('P.*, COUNT(O.product_id) as total');
    $this->db->from('orders AS O');
    $this->db->join('products AS P', 'O.product_id = p.id','INNER');
    $this->db->group_by('O.product_id');
    $this->db->order_by('total','desc');
    $query = $this->db->get();
    return $query->result();        
}
用这一行代码处理这个问题

$this->db->join('products AS P', 'O.product_id = p.id','INNER');

该项目在我的本地机器上正常工作,直到我将其托管在这里查看为止。这一个非常简单。将表的别名声明为P-大写字母:

$this->db->join('products AS P', ...)
但随后通过一个较低的字母表示:
p.id

在Windows上,字母的大小写-
p
p
-无关紧要,而在Linux上(您的主机可能使用它)则无关紧要。因此,要修复此错误,只需键入:

$this->db->join('products AS p', 'O.product_id = p.id','INNER');

将来,对于表和字段,您最好使用严格的小写名称,因为这将适用于任何操作系统。

这一个非常简单。将表的别名声明为P-大写字母:

$this->db->join('products AS P', ...)
但随后通过一个较低的字母表示:
p.id

在Windows上,字母的大小写-
p
p
-无关紧要,而在Linux上(您的主机可能使用它)则无关紧要。因此,要修复此错误,只需键入:

$this->db->join('products AS p', 'O.product_id = p.id','INNER');

将来,您最好对表和字段使用严格的小写名称,因为这在任何操作系统上都适用。

表别名区分大小写。表别名区分大小写。是的,它确实有效,但引发了此错误。查看网站以查看新错误我在这里问了新问题您可以尝试查看它。谢谢。是的,它确实有效,但是抛出了这个错误。查看网站以查看新错误我在这里问了新问题您可以尝试查看它。谢谢