TP5数据操作指定查询字段为结果集key
Db::table( ‘数据表名’ ) -> where( 查询条件 ) -> column( ‘字段列表’, ‘数组键名’ ) ;
Db::table('User')->where(['status'=>['>',0]])->column('id,name,tel','tel');
返回结果
[
'15698963256'=>[
'id'=>1,
'name'=>'小明',
'tel'=>'15698963256'
]
]
Db::table( ‘数据表名’ ) -> where( 查询条件 ) -> column( ‘字段列表’, ‘数组键名’ ) ;
Db::table('User')->where(['status'=>['>',0]])->column('id,name,tel','tel');
返回结果
[
'15698963256'=>[
'id'=>1,
'name'=>'小明',
'tel'=>'15698963256'
]
]