예제 #1
0
 public static function deleteNonce(ezcDbHandler $db, $nonce)
 {
     $options = new ezcAuthenticationOpenidDbStoreOptions();
     $nonces = $options->tableNonces;
     $query = new ezcQueryDelete($db);
     $e = $query->expr;
     $query->deleteFrom($db->quoteIdentifier($nonces['name']))->where($e->eq($db->quoteIdentifier($nonces['fields']['nonce']), $query->bindValue($nonce)));
     $query = $query->prepare();
     $query->execute();
 }
예제 #2
0
 public static function deleteById(ezcDbHandler $db, $id, $prefix = '')
 {
     //$db->beginTransaction();
     $q = $db->createDeleteQuery();
     $q->deleteFrom($db->quoteIdentifier($prefix . 'pipe_execution'))->where($q->expr->eq($db->quoteIdentifier('id'), $q->bindValue((int) $id)));
     $stmt = $q->prepare();
     $stmt->execute();
     $q = $db->createDeleteQuery();
     $q->deleteFrom($db->quoteIdentifier($prefix . 'pipe_execution_state'))->where($q->expr->eq($db->quoteIdentifier('execution_id'), $q->bindValue((int) $id)));
     $stmt = $q->prepare();
     $stmt->execute();
     //$db->commit();
 }
예제 #3
0
 /**
  * Sets the correct id on the insert query.
  *
  * @param ezcPersistentObjectDefinition $def
  * @param ezcDbHandler $db
  * @param ezcQueryInsert $q
  * @return void
  */
 public function preSave(ezcPersistentObjectDefinition $def, ezcDbHandler $db, ezcQueryInsert $q)
 {
     // Sanity check.
     // ID must have been stored during the persistence check before inserting the object.
     if ($this->id === null) {
         throw new ezcPersistentIdentifierGenerationException($def->class, 'ezcPersistentManualGenerator expects the ID to be present before saving.');
     }
     $q->set($db->quoteIdentifier($def->idProperty->columnName), $q->bindValue($this->id, null, $def->idProperty->databaseType));
 }
 /**
  * Returns the current version number for a given workflow name.
  *
  * @param  string $workflowName
  * @return int
  * @throws ezcDbException
  */
 protected function getCurrentVersionNumber($workflowName)
 {
     $query = $this->db->createSelectQuery();
     $query->select($query->alias($query->expr->max($this->db->quoteIdentifier('workflow_version')), 'version'))->from($this->db->quoteIdentifier($this->options['prefix'] . 'workflow'))->where($query->expr->eq($this->db->quoteIdentifier('workflow_name'), $query->bindValue($workflowName)));
     $stmt = $query->prepare();
     $stmt->execute();
     $result = $stmt->fetchAll(PDO::FETCH_ASSOC);
     if ($result !== false && isset($result[0]['version']) && $result[0]['version'] !== null) {
         return $result[0]['version'];
     } else {
         return 0;
     }
 }
 /**
  * Creates a simple JOIN to fetch the objects defined by $relation.
  *
  * Creates a simple LEFT JOIN using the aliases defined in $relation and
  * the $srcTableAlias, to fetch all objects defined by $relation, which are
  * related to the source object, fetched by $srcTableAlias.
  * 
  * @param ezcQuerySelect $q 
  * @param string $srcTableAlias 
  * @param string $dstTableAlias 
  * @param ezcPersistentRelationFindDefinition $relation 
  */
 protected function createSimpleJoin(ezcQuerySelect $q, $srcTableAlias, $dstTableAlias, ezcPersistentRelationFindDefinition $relation)
 {
     $relationDefinition = $relation->relationDefinition;
     $first = true;
     $joinCond = null;
     foreach ($relationDefinition->columnMap as $mapping) {
         $srcColumn = $this->getColumnName($srcTableAlias, $mapping->sourceColumn);
         $destColumn = $this->getColumnName($dstTableAlias, $mapping->destinationColumn);
         if ($first) {
             $joinCond = $q->expr->eq($srcColumn, $destColumn);
             $first = false;
         } else {
             $joinCond = $q->expr->and($joinCond, $q->expr->eq($srcColumn, $destColumn));
         }
     }
     $q->leftJoin($q->alias($this->db->quoteIdentifier($relationDefinition->destinationTable), $this->db->quoteIdentifier($dstTableAlias)), $joinCond);
 }
예제 #6
0
파일: execution.php 프로젝트: bmdevel/ezc
 /**
  * Load execution state.
  *
  * @param int $executionId  ID of the execution to load.
  * @throws ezcWorkflowExecutionException
  */
 protected function loadExecution($executionId)
 {
     $query = $this->db->createSelectQuery();
     $query->select($this->db->quoteIdentifier('workflow_id'))->select($this->db->quoteIdentifier('execution_variables'))->select($this->db->quoteIdentifier('execution_threads'))->select($this->db->quoteIdentifier('execution_next_thread_id'))->select($this->db->quoteIdentifier('execution_waiting_for'))->from($this->db->quoteIdentifier($this->options['prefix'] . 'execution'))->where($query->expr->eq($this->db->quoteIdentifier('execution_id'), $query->bindValue((int) $executionId)));
     $stmt = $query->prepare();
     $stmt->execute();
     $result = $stmt->fetchAll(PDO::FETCH_ASSOC);
     if ($result === false || empty($result)) {
         throw new ezcWorkflowExecutionException('Could not load execution state.');
     }
     $this->id = $executionId;
     $this->nextThreadId = $result[0]['execution_next_thread_id'];
     $this->threads = ezcWorkflowDatabaseUtil::unserialize($result[0]['execution_threads']);
     $this->variables = ezcWorkflowDatabaseUtil::unserialize($result[0]['execution_variables']);
     $this->waitingFor = ezcWorkflowDatabaseUtil::unserialize($result[0]['execution_waiting_for']);
     $workflowId = $result[0]['workflow_id'];
     $this->workflow = $this->properties['definitionStorage']->loadById($workflowId);
     $query = $this->db->createSelectQuery();
     $query->select($this->db->quoteIdentifier('node_id'))->select($this->db->quoteIdentifier('node_state'))->select($this->db->quoteIdentifier('node_activated_from'))->select($this->db->quoteIdentifier('node_thread_id'))->from($this->db->quoteIdentifier($this->options['prefix'] . 'execution_state'))->where($query->expr->eq($this->db->quoteIdentifier('execution_id'), $query->bindValue((int) $executionId)));
     $stmt = $query->prepare();
     $stmt->execute();
     $result = $stmt->fetchAll(PDO::FETCH_ASSOC);
     $active = array();
     foreach ($result as $row) {
         $active[$row['node_id']] = array('activated_from' => ezcWorkflowDatabaseUtil::unserialize($row['node_activated_from']), 'state' => ezcWorkflowDatabaseUtil::unserialize($row['node_state'], null), 'thread_id' => $row['node_thread_id']);
     }
     foreach ($this->workflow->nodes as $node) {
         $nodeId = $node->getId();
         if (isset($active[$nodeId])) {
             $node->setActivationState(ezcWorkflowNode::WAITING_FOR_EXECUTION);
             $node->setThreadId($active[$nodeId]['thread_id']);
             $node->setState($active[$nodeId]['state'], null);
             $node->setActivatedFrom($active[$nodeId]['activated_from']);
             $this->activate($node, false);
         }
     }
     $this->cancelled = false;
     $this->ended = false;
     $this->loaded = true;
     $this->resumed = false;
     $this->suspended = true;
 }