【发布时间】:2021-09-24 07:09:11
【问题描述】:
我正在使用 codeigniter,我想将记录获取为“两个数组” 基于条件(FilterType='Tag',FilterType='Merchant')
这是我的表“filterproducts”
id FilterType CategoryUrl
1 Tag abc
2 Tag xyz
3 Merchant abc
4 Merchant abc
这是我当前的代码,它给了我多维数组
function SearctRecords()
{
$this->db->select("*")
->from("filterproducts fp")
->join("filterid fi", "fp.FilterType=fi.name")
->where("fp.CategoryUrl", $CategoryUrl);
$query = $this->db->get();
$result = $query->result_array();
return $result;
}
这是我的控制器
function SearchFilterProducts()
{
$users['data'] = $this->Customer_model->SearctRecords($CategoryUrl);
$responseJSON = array("Status" => $status, "data" => $users['data']);
header("content-type:application/json");
$response = json_encode($responseJSON);
echo $response;
}
【问题讨论】:
-
你能发布你预期的数组结果吗?
标签: php arrays codeigniter