本文整理汇总了PHP中CActiveRecord::getAttributes方法的典型用法代码示例。如果您正苦于以下问题:PHP CActiveRecord::getAttributes方法的具体用法?PHP CActiveRecord::getAttributes怎么用?PHP CActiveRecord::getAttributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CActiveRecord
的用法示例。
在下文中一共展示了CActiveRecord::getAttributes方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
/**
* Set attributes with attributes of embedded model or values specified in GET params
*/
public function init()
{
$scenario = $this->getScenario();
if ($scenario === 'search' && isset($_GET[get_called_class()])) {
$this->setAttributes($_GET[get_called_class()], false);
} elseif ($this->relatedModel) {
$this->setAttributes($this->relatedModel->getAttributes(), false);
$this->label = $this->relatedModel->getRelationshipLabel($this->myModel);
}
}
示例2: getModelFieldList
public function getModelFieldList()
{
$fields = array_keys(parent::getAttributes());
foreach ($fields as $k => $f) {
if ($this->tableSchema->primaryKey == $f) {
$type = "HiddenField";
} else {
$type = "TextField";
}
$array[] = ['name' => $f, 'type' => $type, 'label' => $this->getAttributeLabel($f)];
}
return $array;
}
示例3: getApiAttributes
/**
* Returns the attributes
*/
public function getApiAttributes($names = true)
{
$attrs = parent::getAttributes($names);
return $attrs;
}
示例4: getElements
/**
* @param CActiveRecord $model
* @param array $attributes
* @return array
*/
public static function getElements($model, $attributes = [])
{
$modelAttributes = $model->getAttributes();
$modelElements = [];
foreach ($modelAttributes as $attrName => $attrVal) {
if (!empty($attributes)) {
foreach ($attributes as $attr) {
if ($attrName === $attr) {
$modelElements[$attr] = ['label' => $model->getAttributeLabel($attr), 'required' => $model->isAttributeRequired($attr), 'type' => 'text'];
}
}
continue;
}
$modelElements[$attrName] = ['label' => $model->getAttributeLabel($attrName), 'required' => $model->isAttributeRequired($attrName), 'type' => 'text'];
// if ($field->inputType == 'dropdownlist') {
// $elements['elements']['contextFields']['elements'][$field->inputName . '-' . $field->id]['items'] =
// Options::model()->getContextFieldOptions($field->id);
// }
}
return $modelElements;
}
示例5: getAttributes
/**
* Returns all attribute and flags values.
* @param array $names list of attributes whose value needs to be returned.
* Defaults to null, meaning all attributes as listed in {@link attributeNames} and flags as listed in
* {@link flagNames} will be returned. If it is an array, only the attributes in the array will be returned.
* @return array attribute values (name=>value).
*/
public function getAttributes($names = null)
{
$attributes = parent::getAttributes($names);
if (is_array($names)) {
$flags = $this->cachedFlags();
$flagNames = array_intersect(array_keys($flags), $names);
foreach ($flagNames as $name) {
$attributes[$name] = $this->getFlag($flags[$name]);
}
}
return $attributes;
}
示例6: attributesOf
/**
* Returns the viewable attributes of an active record model in an array.
*
* @param CActiveRecord $model
*/
public function attributesOf(CActiveRecord $model)
{
if ($model instanceof X2Model) {
$attributes = $model->getAttributes($model->getReadableAttributeNames());
// Kludge for including actionDescription in Actions:
if ($model instanceof Actions && $model->fieldPermissions['actionDescription'] >= 1) {
$attributes['actionDescription'] = $model->getActionDescription();
}
return $attributes;
} elseif ($model instanceof User) {
$excludeAttributes = array_fill_keys(array('password', 'userKey', 'googleRefreshToken'), '');
$attributes = array_diff_key(array_merge($model->attributes, $model->profile->attributes), $excludeAttributes);
$uid = Yii::app()->getSuId();
if (!Yii::app()->authManager->checkAccess('UsersAdmin', $uid) && $model->id != $uid) {
// Attribute whitelisting for privacy
$attributes = array_intersect_key($attributes, array_fill_keys(array('id', 'firstName', 'lastName', 'emailAddress', 'username', 'userAlias', 'fullName'), ''));
}
return $attributes;
} else {
return $model->attributes;
}
}
示例7: getAttributes
/**
* The followings are the available columns in table 'users':
* @var integer $id
* @var string $username
* @var string $full_name
* @var string $password
* @var string $email
* @var string $activkey
* @var integer $createtime
* @var integer $lastvisit
* @var integer $superuser
* @var integer $status
* @var timestamp $create_at
* @var timestamp $lastvisit_at
*/
public function getAttributes($name = true)
{
return parent::getAttributes($name);
}
示例8: copyAttributes
/**
* Copies attributes from one active record to another, skips primary key.
*
* @param CActiveRecord $from record to copy from
* @param CActiveRecord $to record to copy to
* @param array $skipAttributes attribute names which should not be copied
* @param array $forceCopyAttributes attribute names which should be force copied
*/
protected static function copyAttributes($from, $to, $skipAttributes = array(), $forceCopyAttributes = array())
{
$attributes = $from->getAttributes();
$pk = $to->getMetaData()->tableSchema->primaryKey;
if (!is_array($pk)) {
$skipAttributes[] = $pk;
} else {
$skipAttributes = array_merge($skipAttributes, $pk);
}
$skipAttributes = array_diff($skipAttributes, $forceCopyAttributes);
foreach ($skipAttributes as $attribute) {
unset($attributes[$attribute]);
}
$to->setAttributes($attributes, true);
}
示例9: getFilteredAttributes
public function getFilteredAttributes(\CActiveRecord $instance)
{
return $instance->getAttributes(Filter::getFilter($instance->getAttributes(), get_class($instance)));
}
示例10: getAttributes
public function getAttributes($names = true)
{
$attrs = parent::getAttributes($names);
$attrs['displayName'] = $this->username;
$attrs['photoThmbnl64'] = $this->getPhotoThmbnl64();
$attrs['pageUrl'] = $this->pageUrl;
return $attrs;
}
示例11: getAttributes
public function getAttributes($names = true)
{
$attrs = parent::getAttributes($names);
$attrs['imageThmbnl96'] = $this->getImageThmbnl96();
return $attrs;
}