コード例 #1
0
ファイル: BetsModel.php プロジェクト: berksonj/bet
 public function getInfomationByOdds($arrayOfOddIds)
 {
     $oddsIds = implode(',', $arrayOfOddIds);
     $odds = new Model_OddValueModel();
     $betType = new Model_BetsTypeModel();
     $eventBetsModel = new Model_EventBetsModel();
     $this->resetQuery();
     $this->addQuery('select', array('table' => $this->getTableName()));
     $this->addQuery('leftJoin', array('table' => $eventBetsModel->getTableName(), 'condition' => 'bets_id = bets_id_FK'));
     $this->addQuery('leftJoin', array('table' => $betType->getTableName(), 'condition' => 'event_bets_id_FK = event_bets_id'));
     $this->addQuery('leftJoin', array('table' => $odds->getTableName(), 'condition' => 'bet_types_id_FK=bet_types_id'));
     $this->addQuery('where', array('where_condition' => "odd_value_id in ({$oddsIds})"));
     return $this;
 }
コード例 #2
0
ファイル: EventBetDataModel.php プロジェクト: berksonj/bet
 public function load($primKeys)
 {
     if (!isset($primKeys)) {
         $this->setValidationError('sql', 'Load data not set');
     }
     $odds = new Model_OddValueModel();
     $betType = new Model_BetsTypeModel();
     $this->setPrimaryKeysValues($primKeys);
     $this->addQuery('select', array('table' => $this->getTableName()));
     $this->addQuery('leftJoin', array('table' => $betType->getTableName(), 'condition' => 'event_bets_id_FK = event_bets_id'));
     $this->addQuery('leftJoin', array('table' => $odds->getTableName(), 'condition' => 'bet_types_id_FK=bet_types_id'));
     $this->addQuery('where', array('where_condition' => $this->preparePKForWhere()));
     if ($data = $this->executeQuery()) {
         $objectData = $this->getConnection()->fetchAssoc($data);
         $this->setData($objectData[0]);
         foreach ($objectData as $o) {
             $this->addOdds($o);
             $this->addEventTypes($o);
         }
     }
 }
コード例 #3
0
ファイル: EventBetsModel.php プロジェクト: berksonj/bet
 public function update($forceUpdateFlag = false)
 {
     $checkIfModelIsUpdatebale = new Model_EventBetsModel();
     $checkIfModelIsUpdatebale->load($this->getEventBetsId());
     if ($checkIfModelIsUpdatebale->getCorrectType() != null) {
         return $this->setValidationError('update', 'Correct Type is set, Event can be updated anymore');
     }
     parent::update($forceUpdateFlag);
     $this->load($this->getEventBetsId());
     if ($this->getCorrectType() != null) {
         $betTypesModel = new Model_BetsTypeModel();
         $betTypesModel->load(array('event_bets_id_FK' => $this->getEventBetsId(), 'event_types_value_id_FK' => $this->getCorrectType()));
         $betTypesModel->addQuery('select', array('table' => $betTypesModel->getTableName()));
         $betTypesModel->addQuery('where', array('where_condition' => 'event_bets_id_FK=' . $this->getEventBetsId()));
         $betTypesModelCollection = new Core_Model_Adapter_ModelCollection();
         $betTypesModelCollection->getModelCollection($betTypesModel);
         $betTypesKeys = $betTypesModelCollection->getKeysArray('bet_types_id');
         $odds = new Model_OddValueModel();
         $odds->addQuery('update', array('table' => $odds->getTableName(), 'columns' => 'is_correct=0'));
         $odds->addQuery('where', array('where_condition' => 'bet_types_id_FK in (' . implode(',', $betTypesKeys) . ')'));
         $odds->executeQuery();
         $odds->load(array('bet_types_id_FK' => $betTypesModel->getBetTypesId()));
         $odds->setIsCorrect(1);
         $odds->update();
         $odds->addQuery('select', array('table' => $odds->getTableName()));
         $odds->addQuery('where', array('where_condition' => 'bet_types_id_FK in (' . implode(',', $betTypesKeys) . ')'));
         $oddsValuesCollection = new Core_Model_Adapter_ModelCollection();
         $oddsValuesCollection->getModelCollection($odds);
         $oddValuesKeys = $oddsValuesCollection->getKeysArray('odd_value_id');
         $betSlip = new Model_BetSlipModel();
         $betSlip->addQuery('update', array('table' => $betSlip->getTableName(), 'columns' => 'finished = finished+1'));
         $betSlip->addQuery('where', array('where_condition' => 'bet_slip_id in (select bet_slip_id_FK from bet_slip_odds where odd_value_id_FK in  (' . implode(',', $oddValuesKeys) . '))'));
         $betSlip->executeQuery();
         $betSlip->setStatusOne();
         $betSlip->proccessBetSlips();
         $betSlip->setStatusTwo();
     }
 }