Esempio n. 1
0
 public function getData($date = null)
 {
     $dateValidator = new DateValidator();
     $dateValidator->format = Yii::$app->params['DateFormat'];
     $getDT = CurrencyData::find()->select(['letter_code', 'currencyRU', 'currencyUA']);
     if ($date !== null && !empty($date) && $dateValidator->validate($date)) {
         $getDT->where(['source_date' => Yii::$app->formatter->asDate($date, Yii::$app->params['DbFormat'])]);
     }
     $allDataArr = $getDT->asArray()->all();
     if (empty($allDataArr) && $date !== null && !empty($date)) {
         return [];
     }
     return $allDataArr;
     #return array[data] || empty array[]
 }
Esempio n. 2
0
 public function getData($date = null)
 {
     $dateValidator = new DateValidator();
     $dateValidator->format = Yii::$app->params['DateFormat'];
     $getDT = CurrencyData::find();
     if ($date !== null && !empty($date) && $dateValidator->validate($date)) {
         $getDT->where(['source_date' => Yii::$app->formatter->asDate($date, Yii::$app->params['DbFormat'])]);
     }
     $allDataArr = $getDT->asArray()->all();
     //new FullUpdater($date);
     if (empty($allDataArr) && $date !== null && !empty($date)) {
         new FullUpdater($date);
         // 'do update'
         return $this->getData($date);
     }
     return $allDataArr;
     #return array[data] || empty array[]
 }
Esempio n. 3
0
 /** true - insert  false - update */
 private function CheckData($code)
 {
     $chDATA = CurrencyData::find()->where(['digital_code' => $code, 'source_date' => Yii::$app->formatter->asDate($this->InputDate, Yii::$app->params['DbFormat'])])->asArray()->one();
     if (empty($chDATA)) {
         return true;
     } else {
         return $chDATA['id'];
     }
 }