我有 Brand 表(它包含 brand_id、brand_name、b_year )和这段代码
`Products::model()->getAttributeLabel('brand_id')`
var_dump(Products::model()->getAttributeLabel('brand_id'));
它仅显示brand_id 标签。如何显示所有标签而不是一个?
Hii attributeLabels()
是一个function
在Model
. 它返回一个array
withdatabase
字段作为键。
要获得所有标签,您只需调用它而不需要像
var_dump(Products::model()->attributeLabels()); // this will return complete array
getAttributeLabel
写在哪里CActiveRecord
并且它根据定义期望和参数它不会给出所有字段标签
尝试这个
var_dump(Products::model()->attributeLabels());
请试试这个,
$lables = Products::model()->attributeLabels();
print_r($labels);
$lables
Products
从模型返回所有标签。