本文整理汇总了PHP中CActiveRecord::attributeLabels方法的典型用法代码示例。如果您正苦于以下问题:PHP CActiveRecord::attributeLabels方法的具体用法?PHP CActiveRecord::attributeLabels怎么用?PHP CActiveRecord::attributeLabels使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CActiveRecord
的用法示例。
在下文中一共展示了CActiveRecord::attributeLabels方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getModelAttributes
/**
* @param CActiveRecord $model
**/
public function getModelAttributes($model)
{
$result = array();
$attributes = $model->attributeLabels();
// UtilHelper::dump($attributes);
foreach ($attributes as $key => $value) {
$result[$value] = get_class($model) . '.findByPk.' . $key . '|pk=:id';
}
return $result;
}
示例2: export
/**
* @static
* @param CActiveRecord $model
* @param array|string $columns can also passed from js ,if so you can use $_GET to retrive it
* array('id','name') | 'id,name' 或者带别名 't.id,user.name....'
* @param array $headers
*/
public static function export(CActiveRecord $model, $columns = array(), $headers = array())
{
if (isset($_GET[self::$actionKey])) {
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'CSVExport.php';
$provider = $model->search();
if (!empty($columns)) {
$criteria = $provider->getCriteria();
$criteria->select = $columns;
}
$csv = new CSVExport($provider);
if (!empty($headers)) {
$csv->headers = $headers;
}
$csv->headers = $model->attributeLabels();
$csv->exportFull = false;
//default use pagination
if (!empty(self::$options)) {
foreach (self::$options as $key => $value) {
$csv->{$key} = $value;
}
}
// echo var_export($provider->getCriteria()->toArray(),true);
$content = $csv->toCSV(null, "\t", '"');
Yii::app()->getRequest()->sendFile(self::$fileName, $content, "text/csv", false);
die;
// exit;
}
/*
else{
$actionKey = self::$actionKey;
throw new CException("something wrog with your request,must contain the key '{$actionKey}' your get is: ".CJSON::encode($_GET) );
}*/
}
示例3: attributeLabels
/**
* @return array customized attribute labels (name=>label)
*/
public function attributeLabels()
{
return array_merge(parent::attributeLabels(), array('id' => 'ID', 'parent_id' => 'Родитель', 'title' => 'Название', 'description' => 'Описание', 'listorder' => 'Порядок в списке', 'is_locked' => 'Заблокирован?', 'isCat' => 'Категория?'));
}