コード例 #1
0
 /**
  * public $TH;
  * public $A;
  * public $B;
  * public $C;
  * @throws Exception
  * @return boolean
  */
 private static function startMysqlKsdfMemory()
 {
     $ksdf_first = KsdfMemory::findFirst();
     if (isset($ksdf_first->TH)) {
         return true;
     } else {
         try {
             $manager = new TxManager();
             $transaction = $manager->get();
             $ksdf_data = Ksdf::find();
             foreach ($ksdf_data as $ksdf_record) {
                 $ksdf_memory = new KsdfMemory();
                 $ksdf_memory->setTransaction($transaction);
                 $ksdf_memory->TH = $ksdf_record->TH;
                 $ksdf_memory->A = $ksdf_record->A;
                 $ksdf_memory->B = $ksdf_record->B;
                 $ksdf_memory->C = $ksdf_record->C;
                 if ($ksdf_memory->create() == false) {
                     unset($ksdf_data);
                     $transaction->rollback("KSDF DATA INSERT INTO MEMORY TABLE ERROR!");
                 }
             }
             if (isset($ksdf_data)) {
                 unset($ksdf_data);
             }
             $transaction->commit();
             return true;
         } catch (TxFailed $e) {
             throw new Exception("Failed, reason: " . $e->getMessage());
         }
     }
 }
コード例 #2
0
 /**
  * 计算KS基础得分
  * @param \Phalcon\Mvc\Model\Resultsets\Simple $array
  * @return string
  */
 protected static function handle16PF(&$array)
 {
     $array_list = self::strDivideToArray($array->option, $array->question_number_list);
     #判断内存表状态
     if (!self::$memory_state) {
         self::loadMemoryTable();
     }
     $rtn_array = array();
     foreach ($array_list as $array_record) {
         $rtn_array[] = KsdfMemory::getRecord(intval($array_record['number']), strtoupper($array_record['option']));
     }
     return implode('|', $rtn_array);
 }