php - RestApi php中的过滤器数组
问题描述
我正在使用 RestApI IN Codeigniter 我有两个下表
表 - 城市
id city
1 abc
2 xyz
3 abp
4 djh
表 - 位置
id address cityId
1 lorem1 2
2 lorem2 3
3 lorem3 2
4 lorem4 1
这是我的查询,它工作正常,但以以下格式显示
{
"name": "xyz",
"address": "lorem1",
}
{
"name": "xyz",
"address": "lorem3",
}
But i want to result like city list and related address in json
Expected output
cityname : xyz
{
///details of xyz
address : lorem1
address : lorem3
}
cityName :abc
{
address : lorem1
}
...
这是我的查询
$this->db->select('c.*,l.address ');
$this->db->from('city c');
$this->db->join('locality l', 'c.id=l.cityID');
$this->db->order_by("c.name", "asc");
$query = $this->db->get();
if ($query->num_rows() > 0)
{
$rows = $query->result_array();
}
解决方案
推荐阅读
- java - JPA 条件查询:where 子句中带有谓词“in”的子查询
- database - Cosmos DB 未保存所有行
- android - Android API 23 白色状态栏隐藏视图内容
- c# - ASP.NET MVC 使用 json 获取对象 ID
- android - Why my Interstitial Ads show on back button press? Android
- javascript - jquery隐藏和显示复选框事件不起作用
- python - python正则表达式中的两个条件
- ruby-on-rails - 如何将 Rails Web 应用程序作为桌面或离线应用程序运行
- c# - 从转换后的字节字符串中解析特定字符串
- amazon-web-services - 配置 Jenkins 以在 AWS EKS 上部署