简体   繁体   English

如何在mysql结果数组中结合两个过滤查询并在codeigniter中编码json代码?

[英]how to combine two filter query in mysql result array and encode json code in codeigniter?

This query have name table and keyword . 该查询具有名称表和关键字。 First query result for name and their relationship table. 名称及其关系表的第一个查询结果。 Second query result for keyword and their relationship table. 关键字及其关系表的第二查询结果。 I want to combine this statement in one line and then result with JSON encode. 我想将此语句合并为一行,然后使用JSON编码结果。

$query1[] = $this->search_model->get_filter_name($data); 
$query2[] = $this->search_model->get_filter_keyword($data);
$query = array_merge($query1,$query2);
json_encode($query);

Priority, first is name result and second is keyword result. 优先级,第一个是名称结果,第二个是关键字结果。

Just remove bracket from varibable query as below . 只需从可变查询中删除括号,如下所示。

$query1 = $this->search_model->get_filter_name($data); 
$query2 = $this->search_model->get_filter_keyword($data);
$query = array_merge($query1,$query2);
json_encode($query);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM