ThinkPHP查询返回简单字段数组
来源:互联网 发布:投影机的网络接口 编辑:程序博客网 时间:2024/05/22 00:41
使用select语句。返回的都是结构较复杂的字段数组。如以下是一个简单的查询:
$map['parentid'] = $id;
$sub_ids = D('Category')->where($map)->field("catid")->select();
查询后,得到的结果是:
[{"catid":"23"},{"catid":"24"},{"catid":"25"},{"catid":"26"},{"catid":"27"},{"catid":"28"},{"catid":"29"},{"catid":"30"}]
从结构就看出这是结构较复杂的数组,其元素是一个map。
若我们仅仅是需要一个简单的,只包含数字段元素的数组,可以使用以下方法:
$sub_ids = D('Category')->where($map)->getField('catid',true);
查询后,得到的结果是:
["23","24","25","26","27","28","29","30"]
瞬间清爽多了。
0 0
- ThinkPHP查询返回简单字段数组
- thinkphp查询返回简单字段数组例子详解
- thinkPHP 查询数据库字段
- Thinkphp查询控制字段和查询一条
- thinkphp查询条件,数组写法
- thinkphp模型过滤查询字段,表达式方法
- thinkphp模型过滤查询字段,表达式方法
- thinkphp模型过滤查询字段,表达式…
- thinkphp模型过滤查询字段,表达式方法
- thinkphp mysql 字段区间查询 根据范围筛选字段
- Thinkphp 多表查询 join table用法 同名字段查询
- 查询返回的字段显示($,$slice,$elemMatch)
- php 返回查询结果某个字段
- mongodb中查询返回指定字段
- Mybatis查询数据库空字段不返回
- ThinkPHP 在select查询时 无法使用中文字段原因
- thinkphp多表查询两表有重复相同字段解决方法
- mybatis查询字段为空返回另一个字段的值
- iOS shareSDK的分享与第三方登陆 (详解)
- 导出数据到excel工具类
- 用UIButton 自定义UITabbarController+UINavgationController 实现页面跳转
- UvaOJ 537 - Artificial Intelligence?
- linux command to open pdf ,dir, html
- ThinkPHP查询返回简单字段数组
- hbase性能优化大全,很全,很牛
- bash_profile,bashrc,profile等区别
- 【算法导论】第三版课后习题*2.3-7
- java 中 byte Ascii Hex int short 字串之间的互转
- LeetCode: Insertion Sort List
- 数据库设计1
- 什么ppt转换成pdf转换器好
- win8.1中xshell输入中文显示问号问题