本文整理汇总了PHP中YiiBase::endProfile方法的典型用法代码示例。如果您正苦于以下问题:PHP YiiBase::endProfile方法的具体用法?PHP YiiBase::endProfile怎么用?PHP YiiBase::endProfile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类YiiBase
的用法示例。
在下文中一共展示了YiiBase::endProfile方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionProfile
public function actionProfile()
{
YiiBase::beginProfile(1);
Yii::app()->user->setFlash('infomsg', "You now editing profile");
$model = TblProfile::model()->with('photos')->findByAttributes(array('user_id' => Yii::app()->user->getId()));
if (!$model) {
$model = new TblProfile();
}
$model->setScenario('create');
MyClass::dump($model);
$img_add = new TblProfilePhotos();
// uncomment the following code to enable ajax-based validation
if (isset($_POST['ajax']) && $_POST['ajax'] === 'tbl-profile-profile-form') {
$model->setScenario('ajax');
echo CActiveForm::validate($model);
Yii::app()->end();
} elseif (isset($_POST['TblProfile'])) {
//MyClass::dump($_FILES); exit();
$model->attributes = $_POST['TblProfile'];
$model->setAttribute('user_id', Yii::app()->user->getId());
if ($model->validate()) {
// form inputs are valid, do something here
$model->save();
}
if ($_FILES['images']) {
$images = CUploadedFile::getInstancesByName('images');
foreach ($images as $img => $pic) {
if ($pic->saveAs(Yii::getPathOfAlias('webroot') . '/assets/files/' . $pic->name)) {
$img_add = new TblProfilePhotos();
$img_add->setAttribute('image', $pic);
$img_add->setAttribute('name', $pic->name);
//it might be $img_add->name for you, filename is just what I chose to call it in my model
$img_add->setAttribute('profile_id', $model->id);
// this links your picture model to the main model (like your user, or profile model)
if ($img_add->validate()) {
$img_add->save();
// DONE
} else {
break;
}
}
}
/* вариант напрямик
$builder=Yii::app()->db->schema->commandBuilder;
$command=$builder->createMultipleInsertCommand('tbl_user_photos',
array_map(function($arr){
return array('name' => $arr, 'profile_id' => $model->attributes->id);
}, $_FILES['TblProfile']['name']['photos'])
);
$command->execute();
*/
}
}
YiiBase::endProfile(1);
$this->render('profile', array('model' => $model, 'photosModel' => isset($img_add) ? $img_add : null));
}