Exemplo n.º 1
0
 /**
  * public $DM;
  * public $YZ;
  * public $QSF;
  * public $ZZF;
  * public $BZF;
  * @throws Exception
  * @return boolean
  */
 private static function startMysqlKsmdMemory()
 {
     $ksmd_first = KsmdMemory::findFirst();
     if (isset($ksmd_first->YZ)) {
         return true;
     } else {
         try {
             $manager = new TxManager();
             $transaction = $manager->get();
             $ksmd_data = Ksmd::find();
             foreach ($ksmd_data as $ksmd_record) {
                 $ksmd_memory = new KsmdMemory();
                 $ksmd_memory->setTransaction($transaction);
                 $ksmd_memory->DM = $ksmd_record->DM;
                 $ksmd_memory->YZ = $ksmd_record->YZ;
                 $ksmd_memory->QSF = $ksmd_record->QSF;
                 $ksmd_memory->ZZF = $ksmd_record->ZZF;
                 $ksmd_memory->BZF = $ksmd_record->BZF;
                 if ($ksmd_memory->create() == false) {
                     unset($ksmd_data);
                     $transaction->rollback("KSMD DATA INSERT INTO MEMORY TABLE ERROR!");
                 }
             }
             if (isset($ksmd_data)) {
                 unset($ksmd_data);
             }
             $transaction->commit();
             return true;
         } catch (TxFailed $e) {
             throw new Exception("Failed, reason: " . $e->getMessage());
         }
     }
 }