コード例 #1
0
ファイル: Catalog.php プロジェクト: hukumonline/admin
 public function relateTo($itemGuid, $relatedGuid, $as = 'RELATED_ITEM', $valRelation = 0)
 {
     $tblRelatedItem = new App_Model_Db_Table_RelatedItem();
     if (empty($itemGuid)) {
         throw new Zend_Exception('Can not relate to empty GUID');
     }
     $rowsetRelatedItem = $tblRelatedItem->find($itemGuid, $relatedGuid, $as);
     if (count($rowsetRelatedItem) > 0) {
         $row = $rowsetRelatedItem->current();
         $row->valueIntRelation = $valRelation;
     } else {
         $row = $tblRelatedItem->createNew();
         $row->itemGuid = $itemGuid;
         $row->relatedGuid = $relatedGuid;
         $row->relateAs = $as;
         $row->valueIntRelation = $valRelation;
     }
     $row->save();
 }
コード例 #2
0
ファイル: Catalog.php プロジェクト: hukumonline/admin
 public function relateTo($relatedGuid, $as = 'RELATED_ITEM', $valRelation = 0)
 {
     if (empty($this->guid)) {
         throw new Zend_Exception('Can not relate to empty GUID');
     }
     if (empty($relatedGuid)) {
         throw new Zend_Exception('Can not relate to empty related GUID');
     }
     if ($this->guid == $relatedGuid && in_array($as, array('REPEAL', 'AMEND', 'ISROOT'))) {
         return;
     }
     $tblRelatedItem = new App_Model_Db_Table_RelatedItem();
     $rowsetRelatedItem = $tblRelatedItem->find($this->guid, $relatedGuid, $as);
     if (count($rowsetRelatedItem) > 0) {
         $row = $rowsetRelatedItem->current();
         $row->valueIntRelation = $valRelation;
     } else {
         $row = $tblRelatedItem->createNew();
         $row->itemGuid = $this->guid;
         $row->relatedGuid = $relatedGuid;
         $row->relateAs = $as;
         $row->valueIntRelation = $valRelation;
         if (in_array($as, array('REPEAL', 'AMEND', 'ESTABLISH', 'ISROOT'))) {
             $tblRelatedItem = new App_Model_Db_Table_RelatedItem();
             $rowVal = $tblRelatedItem->fetchRow("itemGuid='{$relatedGuid}' AND relateAs IN ('REPEAL','AMEND','ESTABLISH','ISROOT')");
             if ($rowVal && $rowVal->valueStringRelation) {
                 $row->valueStringRelation = $rowVal->valueStringRelation;
             } else {
                 $row->valueStringRelation = $relatedGuid;
             }
             $row->itemType = "history";
         }
     }
     $row->save();
 }