Closed mirgong closed 3 years ago
https://www.easyswoole.com/Components/Orm/toArray.html
https://github.com/easy-swoole/orm/blob/master/tests/CollectionTest.php
get
时无需设置returnCollection
即可调用hidden,visible, append
.
all
需要设置returnCollection
才可以调用,或者foreach -> toArray(false,false)
.
两者前提都需要toArray(false,false)
,你只要能调用到toArray
那么就可以使用.但这样的数据必须toArray(false,false)
才会显示.
$list = DbManager::getInstance()->invoke(function ($client)use ($where,$page,$page_num){ $model = ClientWitnessModel::invoke($client); $fields = "c.*"; $res = $model->alias("c") ->field($fields) ->join("ymt_client_witness_appointment_date as cd",'c.client_witness_id = cd.client_witness_id','LEFT') ->where($where) ->page($page,$page_num) ->group("c.client_witness_id") ->hidden(['c.img','c.img_list']); ->withTotalCount() ->all() ; $total = $model->lastQueryResult()->getTotalCount(); return ['total' => $total, 'list' => $res]; });
sql :SELECT SQL_CALC_FOUND_ROWS c.* FROM ymt_client_witness AS
c
LEFT JOIN ymt_client_witness_appointment_date as cd on c.client_witness_id = cd.client_witness_id WHEREc
.company_id
= 3473 ANDc
.is_open_partner
= 1 GROUP BY c.client_witness_id LIMIT 0, 10结果还是显示了img,img_list,字段并未隐藏,orm 版本:easyswoole/orm 1.4.31 php stander lib