本文整理汇总了PHP中Vote::findAll方法的典型用法代码示例。如果您正苦于以下问题:PHP Vote::findAll方法的具体用法?PHP Vote::findAll怎么用?PHP Vote::findAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vote
的用法示例。
在下文中一共展示了Vote::findAll方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: voteCount
public function voteCount($id, $type)
{
$voteCount = 0;
$votes = Vote::findAll()->where('voteable_id', '=', $id)->where('votable_type', "=", $type);
foreach ($votes as $vote) {
if ($vote == 0) {
$voteCount -= 1;
} else {
$voteCount += 1;
}
return $voteCount;
}
}
示例2: actionFriends
/**
* 好友的投票
*/
public function actionFriends()
{
$uid = Yii::app()->request->getQuery('uid');
$mid = Yii::app()->user->id;
if ($uid == $mid) {
$this->redirect(array('my'));
}
$model = new Vote();
//初始化
$criteria = new CDbCriteria();
$criteria->order = 'ctime DESC';
$criteria->condition = "uid=:uid";
$criteria->params = array(':uid' => $uid);
$date = Yii::app()->request->getQuery('date');
if (!empty($date)) {
$year = $date[0] . $date[1] . $date[2] . $date[3];
$month = $date[4] . $date[5];
$start = mktime(0, 0, 0, $month, 1, $year);
$end = mktime(0, 0, 0, $month + 1, 1, $year);
$condition = "{$start} < ctime AND ctime < {$end}";
$criteria->addCondition($condition);
}
//取得数据总数,分页显示
$total = $model->count($criteria);
$pages = new CPagination($total);
$pages->pageSize = self::PAGE_SIZE;
$pages->applyLimit($criteria);
//获取数据集
$mini_list = $model->findAll($criteria);
$data = array('mini_list' => $mini_list, 'pages' => $pages);
$this->render('my', $data);
}