本文整理汇总了PHP中Properties::setAttributes方法的典型用法代码示例。如果您正苦于以下问题:PHP Properties::setAttributes方法的具体用法?PHP Properties::setAttributes怎么用?PHP Properties::setAttributes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Properties
的用法示例。
在下文中一共展示了Properties::setAttributes方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addProperty
protected function addProperty($data)
{
$userId = Yii::app()->user->getState('id');
$propertyModel = new Properties();
$user2PropertyModel = new User2property();
$userModel = new \User();
$propertyModel->unsetAttributes();
$data['edt'] = new CDbExpression('NOW()');
$propertyModel->setAttributes($data);
$result = $propertyModel->save();
if (!$result) {
return false;
}
$userName = Yii::app()->user->getState('firstname') . ' ' . Yii::app()->user->getState('lastname');
$user2PropertyModel->unsetAttributes();
$user2PropertyModel->setAttributes(array('userId' => $userId, 'propertyId' => $propertyModel->getAttribute('id'), 'access' => UserAccessTable::OWNER, 'status' => UserAccessTable::STATUS_ACTIVE, 'color' => 'type1', 'bookingName' => $userName));
$result = $user2PropertyModel->save();
if (!$result) {
return false;
}
$userModel->unsetAttributes();
$oldId = $userModel->findByPk($userId);
$oldId = $oldId->attributes['property_id'];
$result = $userModel->updateByPk($userId, array('property_id' => $propertyModel->getAttribute('id')));
if (!$result) {
return false;
}
$userControl = new \userControl();
$userControl->update();
$outputArray = array('oldId' => $oldId, 'newId' => $propertyModel->getAttribute('id'));
return $outputArray;
}