public function actionPools() { $pool = Pools::model()->with('answers')->findByPk($_POST['poolId']); if(!PoolsIp::model()->count('ip = :ip AND pool_id = :id', array(':ip'=>$_SERVER['REMOTE_ADDR'], ':id'=>$pool->id))) { if(isset($_POST['value'])) { $pool->hits++; $poolsIp = new PoolsIp(); $poolsIp->answer_id = $_POST['value']; $poolsIp->pool_id = $pool->id; $poolsIp->ip = $_SERVER['REMOTE_ADDR']; $answer = Answers::model()->findByPk($_POST['value']); $answer->hits++; $answer->save(); $poolsIp->save(); $pool->save(); $refreshedPools = Pools::model()->with('answers')->findByPk($_POST['poolId']); $this->renderPartial('pool', array('pool'=>$refreshedPools), false, false); } } }
public function init() { $this->model = Pools::model()->findAll('active = :active', array(':active' => 1)); }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer $id the ID of the model to be loaded * @return Pools the loaded model * @throws CHttpException */ public function loadModel($id) { $model = Pools::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }