Ejemplo n.º 1
0
 /**
  * Get trigger
  *
  * @param string $triggerName
  * @param string $schema
  * @return Object\TriggerObject
  */
 public function getTrigger($triggerName, $schema = null)
 {
     if ($schema === null) {
         $schema = $this->defaultSchema;
     }
     $this->loadTriggerData($schema);
     if (!isset($this->data['triggers'][$schema][$triggerName])) {
         throw new \Exception('Trigger "' . $triggerName . '" does not exist');
     }
     $info = $this->data['triggers'][$schema][$triggerName];
     $trigger = new Object\TriggerObject();
     $trigger->setName($triggerName);
     $trigger->setEventManipulation($info['event_manipulation']);
     $trigger->setEventObjectCatalog($info['event_object_catalog']);
     $trigger->setEventObjectSchema($info['event_object_schema']);
     $trigger->setEventObjectTable($info['event_object_table']);
     $trigger->setActionOrder($info['action_order']);
     $trigger->setActionCondition($info['action_condition']);
     $trigger->setActionStatement($info['action_statement']);
     $trigger->setActionOrientation($info['action_orientation']);
     $trigger->setActionTiming($info['action_timing']);
     $trigger->setActionReferenceOldTable($info['action_reference_old_table']);
     $trigger->setActionReferenceNewTable($info['action_reference_new_table']);
     $trigger->setActionReferenceOldRow($info['action_reference_old_row']);
     $trigger->setActionReferenceNewRow($info['action_reference_new_row']);
     $trigger->setCreated($info['created']);
     return $trigger;
 }
Ejemplo n.º 2
0
 /**
  * $tableName is used by constraint keys.
  */
 protected function loadFromCache($schema, $itemType, $itemName, $tableName = null)
 {
     if ($tableName) {
         if (isset($this->constraintKeys[$schema][$tableName][$itemName])) {
             return;
         }
     } else {
         $prop = $this->keyToProperty($itemType);
         if (isset($this->{$prop}[$schema][$itemName])) {
             return;
         }
     }
     $key = $this->cacheKey($schema . '.' . $itemType . '.' . $itemName);
     $data = $this->cache()->read($key);
     if (!$data) {
         $this->loadAndCache($schema, $itemType, $itemName, $key, $tableName);
     } else {
         switch ($itemType) {
             case 'tb':
                 $object = new ZfObject\TableObject($data['name']);
                 $this->setTableData($object, $data);
                 break;
             case 'vw':
                 $object = new ZfObject\ViewObject($data['name']);
                 $object->setViewDefinition($data['viewDefinition']);
                 $object->setCheckOption($data['checkPption']);
                 $object->setIsUpdatable($data['isUpdatable']);
                 $this->setTableData($object, $data);
                 break;
             case 'ck':
                 $object = new ZfObject\TriggerObject();
                 $object->setOrdinalPosition($data['ordinalPosition']);
                 $object->setReferencedTableSchema($data['referencedTableSchema']);
                 $object->setForeignKeyUpdateRule($data['updateRule']);
                 $object->setForeignKeyDeleteRule($data['deleteRule']);
                 $object->setReferencedTableName($data['referencedTableName']);
                 $object->setReferencedColumnName($data['referencedColumnName']);
                 break;
             case 'tr':
                 $object = new ZfObject\ConstraintKeyObject();
                 $object->setName($data['name']);
                 $object->setEventManipulation($data['eventManipulation']);
                 $object->setEventObjectCatalog($data['eventObjectCatalog']);
                 $object->setEventObjectSchema($data['eventObjectSchema']);
                 $object->setEventObjectTable($data['eventObjectTable']);
                 $object->setActionOrder($data['actionOrder']);
                 $object->setActionCondition($data['actionCondition']);
                 $object->setActionStatement($data['actionStatement']);
                 $object->setActionOrientation($data['actionOrientation']);
                 $object->setActionTiming($data['actionTiming']);
                 $object->setActionReferenceOldTable($data['actionReferenceOldTable']);
                 $object->setActionReferenceNewTable($data['actionReferenceNewTable']);
                 $object->setActionReferenceOldRow($data['actionReferenceOldRow']);
                 $object->setActionReferenceNewRow($data['actionReferenceNewRow']);
                 $object->setCreated($data['created']);
                 break;
         }
         $this->setItem($object, $schema, $itemType, $itemName, $tableName);
     }
 }