Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.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 返回两张带有get_where的表_Php_Codeigniter - Fatal编程技术网

Php 返回两张带有get_where的表

Php 返回两张带有get_where的表,php,codeigniter,Php,Codeigniter,我在php(codeigniter)工作,我想做这个查询 SELECT * FROM families, products WHERE family = "madison" 在这方面,来自 $query = $this->db->get_where("families", array("family" => $key)); 当我尝试 $query = $this->db->get_where("families", "products" arra

我在php(codeigniter)工作,我想做这个查询

SELECT * FROM families, products WHERE family = "madison"
在这方面,来自

        $query = $this->db->get_where("families", array("family" => $key));
当我尝试

$query = $this->db->get_where("families", "products" array("family" => $key));    
它返回错误。有什么办法可以这样做吗

编辑:
发生数据库错误

Error Number: 1054

Unknown column 'products' in 'where clause'

SELECT * FROM (`families`) WHERE `products` IS NULL LIMIT 1

Filename: /Users/Home/Sites/models/family_get.php

Line Number: 5

问题是选择两个表

这不是有效的PHP语法

$query = $this->db->get_where("families", "products" array("family" => $key));
您应该只将两个参数传递给
get\u where
。大概是这样的:

$query = $this->db->get_where("families, products", array("family" => $key));

请注意,
get\u其中
包含四个参数,但您没有使用offset/limit,因此可以省略这些可选参数。

什么是$key?在代码中,$键应该是“madison”或任何其他调用的字符串。在其他一些情况下可能是int。只是我不知道如何查询两个表,然后返回所有信息echo
$this->db->last\u query()
,以打印出结果查询是什么。您将能够看到它是否正在创建意外查询。解析错误:语法错误,第5行/Users/Home/Sites/application/models/family_get.php中的意外“array”(T_array),在
“products”
get_之后需要逗号,其中最多需要4个参数。get_where可以接受两个以上的参数……$query=$this->db->get_where('mytable',array('id'=>$id),$limit,$offset);谢谢,那么选择或可能加入的内容和选项是什么?我从来没有做过一件事join@VictorKilo,我忘了补偿/限制。谢谢,根据您的评论更新了我的答案。@Venkat,谢谢您指出这一点。最后两个参数与此问题无关,但无论如何都会更新以确保正确性。