public function GetNumeroApostaVisitante($id) { $model = new Aposta(); $Criteria = new CDbCriteria(); $Criteria->condition = "id_confronto = {$id} and placar_casa < placar_visitante"; $model = Aposta::model()->findAll($Criteria); $conta = 0; foreach ($model as $item) { $conta = $conta + 1; } return $conta; }
public function GetErros($id) { $Criteria = new CDbCriteria(); $Criteria->condition = "id_user={$id}"; $modelAposta = Rank::model()->findAll($Criteria); $model = Aposta::model()->findAll($Criteria); $total = 0; $totalAposta = 0; foreach ($modelAposta as $item) { $total = $total + 1; } foreach ($model as $item) { $totalAposta = $totalAposta + 1; } return $totalAposta - $total; }
/** * 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 Aposta the loaded model * @throws CHttpException */ public function loadModel($id) { $model = Aposta::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }