本文整理汇总了PHP中Vote::setAttributes方法的典型用法代码示例。如果您正苦于以下问题:PHP Vote::setAttributes方法的具体用法?PHP Vote::setAttributes怎么用?PHP Vote::setAttributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vote
的用法示例。
在下文中一共展示了Vote::setAttributes方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionAddVote
public function actionAddVote()
{
if (Yii::app()->request->isPostRequest && Yii::app()->request->isAjaxRequest) {
$modelType = Yii::app()->request->getPost('modelType');
$model_id = (int) Yii::app()->request->getPost('model_id');
$value = (int) Yii::app()->request->getPost('value');
if (!$model_id || !$value || !$modelType) {
Yii::app()->ajax->failure(Yii::t('VoteModule.vote', 'Произошла ошибка!'));
}
$model = new Vote();
$model->setAttributes(array('model' => $modelType, 'model_id' => $model_id, 'value' => $value));
if ($model->save()) {
Yii::app()->ajax->success();
}
Yii::app()->ajax->failure(Yii::t('VoteModule.vote', 'Произошла ошибка!'));
}
throw new CHttpException(404, Yii::t('VoteModule.vote', 'Страница не найдена!'));
}
示例2: actionCreate
public function actionCreate($sid, $uid)
{
//var_dump($_POST);
$criteria = new CDbCriteria();
$criteria->condition = 'uid=:uid AND sid=:sid';
$criteria->params = array(':uid' => $uid, ':sid' => $sid);
$vote = Vote::model()->findAll($criteria);
if ($vote) {
$this->renderPartial('error', array('error_code' => '3', 'sid' => $sid));
} else {
if (isset($_POST['selectdel'])) {
$count = count($_POST['selectdel']);
$voteself = taxonomy_term_load($sid);
$maxChoose = $voteself->field_limit['und'][0]['value'];
//if($count>$maxChoose)
if ($count < $maxChoose) {
/* $this->renderPartial('result',array(
'info'=>'0',
)); */
$this->renderPartial('error', array('error_code' => '4', 'maxChoose' => $maxChoose, 'sid' => $sid));
} else {
if ($count > $maxChoose) {
/* $this->renderPartial('result',array(
'info'=>'0',
)); */
$this->renderPartial('error', array('error_code' => '5', 'maxChoose' => $maxChoose, 'sid' => $sid));
} else {
foreach ($_POST['selectdel'] as $itemid) {
$model = new Vote();
$model->setAttributes(array('sid' => $sid, 'nid' => $itemid, 'uid' => $uid));
$model->save(true);
$item = node_load($itemid);
$item->field_vote['und'][0]['value'] = $item->field_vote['und'][0]['value'] + 1;
node_save($item);
}
$this->renderPartial('error', array('error_code' => '6', 'sid' => $sid));
}
}
} else {
$this->renderPartial('error', array('error_code' => '7', 'sid' => $sid));
}
}
}