它有一个表格和一个模型,几个参数条目作为标签输出。
name
网站上显示的名称,val
值(通常从 0 到 10-20 ),section
该参数所属节的属性
我正在尝试从表值中选择section='access'
作为数组并替换为DepDrop
.
我这样做:
$options=$options::find(['LIKE', 'section', 'access'])->orderBy('prior')->asArray()->all();
我得到所有记录:
Array ( [0] => Array ( [id] => 1 [name] => Для всех пользователей [val] => 0 [section] => access [prior] => 0 [name_en] => access_1 ) [1] => Array ( [id] => 5 [name] => Командное [val] => 0 [section] => eventtype [prior] => 0 [name_en] => eventtype_1 ) [2] => Array ( [id] => 2 [name] => Для друзей (семья входит в друзья) [val] => 1 [section] => access [prior] => 1 [name_en] => access_2 ) [3] => Array ( [id] => 6 [name] => Семейное [val] => 1 [section] => eventtype [prior] => 1 [name_en] => eventtype_2 ) [4] => Array ( [id] => 3 [name] => Только для семьи [val] => 2 [section] => access [prior] => 2 [name_en] => access_3 ) [5] => Array ( [id] => 7 [name] => Личное [val] => 2 [section] => eventtype [prior] => 2 [name_en] => eventtype_2 ) [6] => Array ( [id] => 4 [name] => Только мне лично [val] => 3 [section] => access [prior] => 3 [name_en] => access_4 ) )
告诉我我做错了什么?
以为有问题Like
,写道:
find(['section' => 'access'])
结果是一样的?
根据文档,请求如下。
$customers = Customer::find()->where(['section' => 'access'])->all();
那些。搜索参数在where函数中指定(多选也可以看andWhere解决方案)。最后,你应该得到类似的东西
$options->$options::find()->where(['section' => 'access'])-orderBy('prior')->asArray->all();
我建议你经常光顾这里。这真的会节省很多时间。