Пример #1
0
 public function postSave()
 {
     $queries = $this->generateQueryVariant();
     $findInteractQuery = array();
     $allInteractQueries = interactQuery::byInteractDefId($this->getId());
     foreach ($queries as $query) {
         $interactQuery = interactQuery::byQuery($query['query'], $this->getId());
         if (!is_object($interactQuery)) {
             $interactQuery = new interactQuery();
         }
         $interactQuery->setInteractDef_id($this->getId());
         $interactQuery->setQuery($query['query']);
         $interactQuery->setLink_type($query['link_type']);
         $interactQuery->setLink_id($query['link_id']);
         $interactQuery->save();
         $findInteractQuery[$interactQuery->getId()] = true;
     }
     foreach ($allInteractQueries as $interactQueries) {
         if (!isset($findInteractQuery[$interactQueries->getId()])) {
             $interactQueries->remove();
         }
     }
 }
Пример #2
0
 public function postSave()
 {
     $queries = $this->generateQueryVariant();
     interactQuery::removeByInteractDefId($this->getId());
     DB::beginTransaction();
     foreach ($queries as $query) {
         $interactQuery = new interactQuery();
         $interactQuery->setInteractDef_id($this->getId());
         $interactQuery->setQuery($query['query']);
         $interactQuery->setActions('cmd', $query['cmd']);
         $interactQuery->save();
     }
     DB::commit();
 }