createUpdateQuery() публичный Метод

Create update Query object.
public createUpdateQuery ( ) : eZ\Publish\Core\Persistence\Database\UpdateQuery
Результат eZ\Publish\Core\Persistence\Database\UpdateQuery
Пример #1
0
 /**
  * Deletes the relation with the given $relationId.
  *
  * @param int $relationId
  * @param int $type {@see \eZ\Publish\API\Repository\Values\Content\Relation::COMMON,
  *                 \eZ\Publish\API\Repository\Values\Content\Relation::EMBED,
  *                 \eZ\Publish\API\Repository\Values\Content\Relation::LINK,
  *                 \eZ\Publish\API\Repository\Values\Content\Relation::FIELD}
  */
 public function deleteRelation($relationId, $type)
 {
     // Legacy Storage stores COMMON, LINK and EMBED types using bitmask, therefore first load
     // existing relation type by given $relationId for comparison
     /** @var $query \eZ\Publish\Core\Persistence\Database\SelectQuery */
     $query = $this->dbHandler->createSelectQuery();
     $query->select($this->dbHandler->quoteColumn('relation_type'))->from($this->dbHandler->quoteTable('ezcontentobject_link'))->where($query->expr->eq($this->dbHandler->quoteColumn('id'), $query->bindValue($relationId, null, \PDO::PARAM_INT)));
     $statement = $query->prepare();
     $statement->execute();
     $loadedRelationType = $statement->fetchColumn();
     if (!$loadedRelationType) {
         return;
     }
     // If relation type matches then delete
     if ($loadedRelationType == $type) {
         /** @var $query \eZ\Publish\Core\Persistence\Database\DeleteQuery */
         $query = $this->dbHandler->createDeleteQuery();
         $query->deleteFrom('ezcontentobject_link')->where($query->expr->eq($this->dbHandler->quoteColumn('id'), $query->bindValue($relationId, null, \PDO::PARAM_INT)));
         $query->prepare()->execute();
     } elseif ($loadedRelationType & $type) {
         // If relation type is composite update bitmask
         /** @var $query \eZ\Publish\Core\Persistence\Database\UpdateQuery */
         $query = $this->dbHandler->createUpdateQuery();
         $query->update($this->dbHandler->quoteTable('ezcontentobject_link'))->set($this->dbHandler->quoteColumn('relation_type'), $query->expr->bitAnd($this->dbHandler->quoteColumn('relation_type'), $query->bindValue(~$type, null, \PDO::PARAM_INT)))->where($query->expr->eq($this->dbHandler->quoteColumn('id'), $query->bindValue($relationId, null, \PDO::PARAM_INT)));
         $query->prepare()->execute();
     } else {
         // No match, do nothing
     }
 }
 function convertFields(OutputInterface $output)
 {
     $query = $this->db->createSelectQuery();
     $query->select($query->expr->count('*'));
     $query->from('ezcontentobject_attribute');
     $query->where($query->expr->eq($this->db->quoteIdentifier('data_type_string'), $query->bindValue('ezxmltext', null, PDO::PARAM_STR)));
     $statement = $query->prepare();
     $statement->execute();
     $count = $statement->fetchColumn();
     $output->writeln("Found {$count} field rows to convert.");
     $query = $this->db->createSelectQuery();
     $query->select('*');
     $query->from('ezcontentobject_attribute');
     $query->where($query->expr->eq($this->db->quoteIdentifier('data_type_string'), $query->bindValue('ezxmltext', null, PDO::PARAM_STR)));
     $statement = $query->prepare();
     $statement->execute();
     while ($row = $statement->fetch(PDO::FETCH_ASSOC)) {
         if (empty($row['data_text'])) {
             $inputValue = Value::EMPTY_VALUE;
         } else {
             $inputValue = $row['data_text'];
         }
         $converted = $this->convert($inputValue);
         $updateQuery = $this->db->createUpdateQuery();
         $updateQuery->update($this->db->quoteIdentifier('ezcontentobject_attribute'));
         $updateQuery->set($this->db->quoteIdentifier('data_type_string'), $updateQuery->bindValue('ezrichtext', null, PDO::PARAM_STR));
         $updateQuery->set($this->db->quoteIdentifier('data_text'), $updateQuery->bindValue($converted, null, PDO::PARAM_STR));
         $updateQuery->where($updateQuery->expr->lAnd($updateQuery->expr->eq($this->db->quoteIdentifier('id'), $updateQuery->bindValue($row['id'], null, PDO::PARAM_INT)), $updateQuery->expr->eq($this->db->quoteIdentifier('version'), $updateQuery->bindValue($row['version'], null, PDO::PARAM_INT))));
         $updateQuery->prepare()->execute();
         $this->logger->info("Converted ezxmltext field #{$row['id']} to richtext", ['original' => $inputValue, 'converted' => $converted]);
     }
     $output->writeln("Converted {$count} ezxmltext fields to richtext");
 }
 /**
  * Update the user information specified by the user struct
  *
  * @param User $user
  */
 public function updateUser(User $user)
 {
     $query = $this->handler->createUpdateQuery();
     $query->update($this->handler->quoteTable('ezuser'))->set($this->handler->quoteColumn('login'), $query->bindValue($user->login))->set($this->handler->quoteColumn('email'), $query->bindValue($user->email))->set($this->handler->quoteColumn('password_hash'), $query->bindValue($user->passwordHash))->set($this->handler->quoteColumn('password_hash_type'), $query->bindValue($user->hashAlgorithm))->where($query->expr->eq($this->handler->quoteColumn('contentobject_id'), $query->bindValue($user->id, null, \PDO::PARAM_INT)));
     $query->prepare()->execute();
     $query = $this->handler->createUpdateQuery();
     $query->update($this->handler->quoteTable('ezuser_setting'))->set($this->handler->quoteColumn('is_enabled'), $query->bindValue($user->isEnabled, null, \PDO::PARAM_INT))->set($this->handler->quoteColumn('max_login'), $query->bindValue($user->maxLogin, null, \PDO::PARAM_INT))->where($query->expr->eq($this->handler->quoteColumn('user_id'), $query->bindValue($user->id, null, \PDO::PARAM_INT)));
     $query->prepare()->execute();
 }
 /**
  * Updates single row data matched by composite primary key.
  *
  * Use optional parameter $languageMaskMatch to additionally limit the query match with languages.
  *
  * @param mixed $parentId
  * @param string $textMD5
  * @param array $values associative array with column names as keys and column values as values
  *
  * @return void
  */
 public function updateRow($parentId, $textMD5, array $values)
 {
     /** @var $query \eZ\Publish\Core\Persistence\Database\UpdateQuery */
     $query = $this->dbHandler->createUpdateQuery();
     $query->update($this->dbHandler->quoteTable("ezurlalias_ml"));
     $this->setQueryValues($query, $values);
     $query->where($query->expr->lAnd($query->expr->eq($this->dbHandler->quoteColumn("parent"), $query->bindValue($parentId, null, \PDO::PARAM_INT)), $query->expr->eq($this->dbHandler->quoteColumn("text_md5"), $query->bindValue($textMD5, null, \PDO::PARAM_STR))));
     $query->prepare()->execute();
 }
Пример #5
0
 /**
  * Updated subtree modification time for all tags in path.
  *
  * @param string $pathString
  * @param int $timestamp
  */
 public function updateSubtreeModificationTime($pathString, $timestamp = null)
 {
     $tagIds = array_filter(explode('/', $pathString));
     if (empty($tagIds)) {
         return;
     }
     $query = $this->handler->createUpdateQuery();
     $query->update($this->handler->quoteTable('eztags'))->set($this->handler->quoteColumn('modified'), $query->bindValue($timestamp ?: time(), null, PDO::PARAM_INT))->where($query->expr->in($this->handler->quoteColumn('id'), $tagIds));
     $query->prepare()->execute();
 }
Пример #6
0
 /**
  * Update object count for words (legacy db table: ezsearch_word).
  *
  * @param array $wordId list of word IDs
  * @param array $columns map of columns and values to be updated ([column => value])
  */
 private function updateWordObjectCount(array $wordId, array $columns)
 {
     $query = $this->dbHandler->createUpdateQuery();
     $query->update($this->dbHandler->quoteTable('ezsearch_word'));
     foreach ($columns as $column => $value) {
         $query->set($this->dbHandler->quoteColumn($column), $value);
     }
     $query->where($query->expr->in($this->dbHandler->quoteColumn('id'), $wordId));
     $stmt = $query->prepare();
     $stmt->execute();
 }
 /**
  * Publishes the Type with $typeId from $sourceVersion to $targetVersion,
  * including its fields
  *
  * @param int $typeId
  * @param int $sourceVersion
  * @param int $targetVersion
  *
  * @return void
  */
 public function publishTypeAndFields($typeId, $sourceVersion, $targetVersion)
 {
     $query = $this->dbHandler->createUpdateQuery();
     $query->update($this->dbHandler->quoteTable('ezcontentclass'))->set($this->dbHandler->quoteColumn('version'), $query->bindValue($targetVersion, null, \PDO::PARAM_INT))->where($query->expr->lAnd($query->expr->eq($this->dbHandler->quoteColumn('id'), $query->bindValue($typeId, null, \PDO::PARAM_INT)), $query->expr->eq($this->dbHandler->quoteColumn('version'), $query->bindValue($sourceVersion, null, \PDO::PARAM_INT))));
     $query->prepare()->execute();
     $query = $this->dbHandler->createUpdateQuery();
     $query->update($this->dbHandler->quoteTable('ezcontentclass_classgroup'))->set($this->dbHandler->quoteColumn('contentclass_version'), $query->bindValue($targetVersion, null, \PDO::PARAM_INT))->where($query->expr->lAnd($query->expr->eq($this->dbHandler->quoteColumn('contentclass_id'), $query->bindValue($typeId, null, \PDO::PARAM_INT)), $query->expr->eq($this->dbHandler->quoteColumn('contentclass_version'), $query->bindValue($sourceVersion, null, \PDO::PARAM_INT))));
     $query->prepare()->execute();
     $query = $this->dbHandler->createUpdateQuery();
     $query->update($this->dbHandler->quoteTable('ezcontentclass_attribute'))->set($this->dbHandler->quoteColumn('version'), $query->bindValue($targetVersion, null, \PDO::PARAM_INT))->where($query->expr->lAnd($query->expr->eq($this->dbHandler->quoteColumn('contentclass_id'), $query->bindValue($typeId, null, \PDO::PARAM_INT)), $query->expr->eq($this->dbHandler->quoteColumn('version'), $query->bindValue($sourceVersion, null, \PDO::PARAM_INT))));
     $query->prepare()->execute();
     $query = $this->dbHandler->createUpdateQuery();
     $query->update($this->dbHandler->quoteTable('ezcontentclass_name'))->set($this->dbHandler->quoteColumn('contentclass_version'), $query->bindValue($targetVersion, null, \PDO::PARAM_INT))->where($query->expr->lAnd($query->expr->eq($this->dbHandler->quoteColumn('contentclass_id'), $query->bindValue($typeId, null, \PDO::PARAM_INT)), $query->expr->eq($this->dbHandler->quoteColumn('contentclass_version'), $query->bindValue($sourceVersion, null, \PDO::PARAM_INT))));
     $query->prepare()->execute();
 }
Пример #8
0
 /**
  * Changes main location of content identified by given $contentId to location identified by given $locationId.
  *
  * Updates ezcontentobject_tree table for the given $contentId and eznode_assignment table for the given
  * $contentId, $parentLocationId and $versionNo
  *
  * @param mixed $contentId
  * @param mixed $locationId
  * @param mixed $versionNo version number, needed to update eznode_assignment table
  * @param mixed $parentLocationId parent location of location identified by $locationId, needed to update
  *        eznode_assignment table
  */
 public function changeMainLocation($contentId, $locationId, $versionNo, $parentLocationId)
 {
     // Update ezcontentobject_tree table
     $q = $this->handler->createUpdateQuery();
     $q->update($this->handler->quoteTable('ezcontentobject_tree'))->set($this->handler->quoteColumn('main_node_id'), $q->bindValue($locationId, null, \PDO::PARAM_INT))->where($q->expr->eq($this->handler->quoteColumn('contentobject_id'), $q->bindValue($contentId, null, \PDO::PARAM_INT)));
     $q->prepare()->execute();
     // Erase is_main in eznode_assignment table
     $q = $this->handler->createUpdateQuery();
     $q->update($this->handler->quoteTable('eznode_assignment'))->set($this->handler->quoteColumn('is_main'), $q->bindValue(0, null, \PDO::PARAM_INT))->where($q->expr->lAnd($q->expr->eq($this->handler->quoteColumn('contentobject_id'), $q->bindValue($contentId, null, \PDO::PARAM_INT)), $q->expr->eq($this->handler->quoteColumn('contentobject_version'), $q->bindValue($versionNo, null, \PDO::PARAM_INT)), $q->expr->neq($this->handler->quoteColumn('parent_node'), $q->bindValue($parentLocationId, null, \PDO::PARAM_INT))));
     $q->prepare()->execute();
     // Set new is_main in eznode_assignment table
     $q = $this->handler->createUpdateQuery();
     $q->update($this->handler->quoteTable('eznode_assignment'))->set($this->handler->quoteColumn('is_main'), $q->bindValue(1, null, \PDO::PARAM_INT))->where($q->expr->lAnd($q->expr->eq($this->handler->quoteColumn('contentobject_id'), $q->bindValue($contentId, null, \PDO::PARAM_INT)), $q->expr->eq($this->handler->quoteColumn('contentobject_version'), $q->bindValue($versionNo, null, \PDO::PARAM_INT)), $q->expr->eq($this->handler->quoteColumn('parent_node'), $q->bindValue($parentLocationId, null, \PDO::PARAM_INT))));
     $q->prepare()->execute();
 }
 /**
  * Publish the specified role draft.
  * If the draft was created from an existing role, published version will take the original role ID.
  *
  * @param mixed $roleDraftId
  * @param mixed|null $originalRoleId ID of role the draft was created from. Will be null if the role draft was completely new.
  */
 public function publishRoleDraft($roleDraftId, $originalRoleId = null)
 {
     $query = $this->handler->createUpdateQuery();
     $query->update($this->handler->quoteTable('ezrole'))->set($this->handler->quoteColumn('version'), $query->bindValue(Role::STATUS_DEFINED, null, \PDO::PARAM_INT));
     // Draft was created from an existing role, so published role must get the original ID.
     if ($originalRoleId !== null) {
         $query->set($this->handler->quoteColumn('id'), $query->bindValue($originalRoleId, null, \PDO::PARAM_INT));
     }
     $query->where($query->expr->eq($this->handler->quoteColumn('id'), $query->bindValue($roleDraftId, null, \PDO::PARAM_INT)));
     $statement = $query->prepare();
     $statement->execute();
     $policyQuery = $this->handler->createUpdateQuery();
     $policyQuery->update($this->handler->quoteTable('ezpolicy'))->set($this->handler->quoteColumn('original_id'), $policyQuery->bindValue(0, null, \PDO::PARAM_INT));
     // Draft was created from an existing role, so published policies must get the original role ID.
     if ($originalRoleId !== null) {
         $policyQuery->set($this->handler->quoteColumn('role_id'), $policyQuery->bindValue($originalRoleId, null, \PDO::PARAM_INT));
     }
     $policyQuery->where($policyQuery->expr->eq($this->handler->quoteColumn('role_id'), $policyQuery->bindValue($roleDraftId, null, \PDO::PARAM_INT)));
     $queryStatement = $policyQuery->prepare();
     $queryStatement->execute();
 }
Пример #10
0
 /**
  * Updates the object state priority to provided value
  *
  * @param mixed $stateId
  * @param int $priority
  */
 public function updateObjectStatePriority($stateId, $priority)
 {
     $query = $this->dbHandler->createUpdateQuery();
     $query->update($this->dbHandler->quoteTable('ezcobj_state'))->set($this->dbHandler->quoteColumn('priority'), $query->bindValue($priority, null, \PDO::PARAM_INT))->where($query->expr->eq($this->dbHandler->quoteColumn('id'), $query->bindValue($stateId, null, \PDO::PARAM_INT)));
     $query->prepare()->execute();
 }