本文整理汇总了PHP中eZ\Publish\Core\Persistence\Database\DatabaseHandler::createInsertQuery方法的典型用法代码示例。如果您正苦于以下问题:PHP DatabaseHandler::createInsertQuery方法的具体用法?PHP DatabaseHandler::createInsertQuery怎么用?PHP DatabaseHandler::createInsertQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZ\Publish\Core\Persistence\Database\DatabaseHandler
的用法示例。
在下文中一共展示了DatabaseHandler::createInsertQuery方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: insertUrlWildcard
/**
* Inserts the given UrlWildcard.
*
* @param \eZ\Publish\SPI\Persistence\Content\UrlWildcard $urlWildcard
*
* @return mixed
*/
public function insertUrlWildcard(UrlWildcard $urlWildcard)
{
/** @var $query \eZ\Publish\Core\Persistence\Database\InsertQuery */
$query = $this->dbHandler->createInsertQuery();
$query->insertInto($this->dbHandler->quoteTable('ezurlwildcard'))->set($this->dbHandler->quoteColumn('destination_url'), $query->bindValue(trim($urlWildcard->destinationUrl, '/ '), null, \PDO::PARAM_STR))->set($this->dbHandler->quoteColumn('id'), $this->dbHandler->getAutoIncrementValue('ezurlwildcard', 'id'))->set($this->dbHandler->quoteColumn('source_url'), $query->bindValue(trim($urlWildcard->sourceUrl, '/ '), null, \PDO::PARAM_STR))->set($this->dbHandler->quoteColumn('type'), $query->bindValue($urlWildcard->forward ? 1 : 2, null, \PDO::PARAM_INT));
$query->prepare()->execute();
return $this->dbHandler->lastInsertId($this->dbHandler->getSequenceName('ezurlwildcard', 'id'));
}
示例2: insertRelation
/**
* Inserts a new relation database record.
*
* @param \eZ\Publish\SPI\Persistence\Content\Relation\CreateStruct $createStruct
*
* @return int ID the inserted ID
*/
public function insertRelation(RelationCreateStruct $createStruct)
{
$q = $this->dbHandler->createInsertQuery();
$q->insertInto($this->dbHandler->quoteTable('ezcontentobject_link'))->set($this->dbHandler->quoteColumn('id'), $this->dbHandler->getAutoIncrementValue('ezcontentobject_link', 'id'))->set($this->dbHandler->quoteColumn('contentclassattribute_id'), $q->bindValue((int) $createStruct->sourceFieldDefinitionId, null, \PDO::PARAM_INT))->set($this->dbHandler->quoteColumn('from_contentobject_id'), $q->bindValue($createStruct->sourceContentId, null, \PDO::PARAM_INT))->set($this->dbHandler->quoteColumn('from_contentobject_version'), $q->bindValue($createStruct->sourceContentVersionNo, null, \PDO::PARAM_INT))->set($this->dbHandler->quoteColumn('relation_type'), $q->bindValue($createStruct->type, null, \PDO::PARAM_INT))->set($this->dbHandler->quoteColumn('to_contentobject_id'), $q->bindValue($createStruct->destinationContentId, null, \PDO::PARAM_INT));
$q->prepare()->execute();
return $this->dbHandler->lastInsertId($this->dbHandler->getSequenceName('ezcontentobject_link', 'id'));
}
示例3: assignRole
/**
* Assigns role to user with given limitation
*
* @param mixed $contentId
* @param mixed $roleId
* @param array $limitation
*/
public function assignRole( $contentId, $roleId, array $limitation )
{
foreach ( $limitation as $identifier => $values )
{
foreach ( $values as $value )
{
$query = $this->handler->createInsertQuery();
$query
->insertInto( $this->handler->quoteTable( 'ezuser_role' ) )
->set(
$this->handler->quoteColumn( 'contentobject_id' ),
$query->bindValue( $contentId, null, \PDO::PARAM_INT )
)->set(
$this->handler->quoteColumn( 'role_id' ),
$query->bindValue( $roleId, null, \PDO::PARAM_INT )
)->set(
$this->handler->quoteColumn( 'limit_identifier' ),
$query->bindValue( $identifier )
)->set(
$this->handler->quoteColumn( 'limit_value' ),
$query->bindValue( $value )
);
$query->prepare()->execute();
}
}
}
示例4: insertTagKeywords
/**
* Inserts keywords for tag with provided tag ID.
*
* @param mixed $tagId
* @param array $keywords
* @param string $mainLanguageCode
* @param bool $alwaysAvailable
*/
protected function insertTagKeywords($tagId, array $keywords, $mainLanguageCode, $alwaysAvailable)
{
foreach ($keywords as $languageCode => $keyword) {
$query = $this->handler->createInsertQuery();
$query->insertInto($this->handler->quoteTable('eztags_keyword'))->set($this->handler->quoteColumn('keyword_id'), $query->bindValue($tagId, null, PDO::PARAM_INT))->set($this->handler->quoteColumn('language_id'), $query->bindValue($this->languageHandler->loadByLanguageCode($languageCode)->id + (int) ($languageCode === $mainLanguageCode && $alwaysAvailable), null, PDO::PARAM_INT))->set($this->handler->quoteColumn('keyword'), $query->bindValue($keyword, null, PDO::PARAM_STR))->set($this->handler->quoteColumn('locale'), $query->bindValue($languageCode, null, PDO::PARAM_STR))->set($this->handler->quoteColumn('status'), $query->bindValue(1, null, PDO::PARAM_INT));
$query->prepare()->execute();
}
}
示例5: insertObjectStateGroupTranslations
/**
* Inserts object state group translations into database
*
* @param \eZ\Publish\SPI\Persistence\Content\ObjectState\Group $objectStateGroup
*/
protected function insertObjectStateGroupTranslations(Group $objectStateGroup)
{
foreach ($objectStateGroup->languageCodes as $languageCode) {
$languageId = $this->maskGenerator->generateLanguageIndicator($languageCode, $languageCode === $objectStateGroup->defaultLanguage);
$query = $this->dbHandler->createInsertQuery();
$query->insertInto($this->dbHandler->quoteTable('ezcobj_state_group_language'))->set($this->dbHandler->quoteColumn('contentobject_state_group_id'), $query->bindValue($objectStateGroup->id, null, \PDO::PARAM_INT))->set($this->dbHandler->quoteColumn('description'), $query->bindValue($objectStateGroup->description[$languageCode]))->set($this->dbHandler->quoteColumn('name'), $query->bindValue($objectStateGroup->name[$languageCode]))->set($this->dbHandler->quoteColumn('language_id'), $query->bindValue($languageId, null, \PDO::PARAM_INT))->set($this->dbHandler->quoteColumn('real_language_id'), $query->bindValue($languageId & ~1, null, \PDO::PARAM_INT));
$query->prepare()->execute();
}
}
示例6: addObjectWordLink
/**
* Link word with specific content object (legacy db table: ezsearch_object_word_link).
*
* @param $wordId
* @param $contentId
* @param $frequency
* @param $placement
* @param $nextWordId
* @param $prevWordId
* @param $contentTypeId
* @param $fieldTypeId
* @param $published
* @param $sectionId
* @param $identifier
* @param $integerValue
*/
public function addObjectWordLink($wordId, $contentId, $frequency, $placement, $nextWordId, $prevWordId, $contentTypeId, $fieldTypeId, $published, $sectionId, $identifier, $integerValue)
{
$assoc = ['word_id' => $wordId, 'contentobject_id' => $contentId, 'frequency' => $frequency, 'placement' => $placement, 'next_word_id' => $nextWordId, 'prev_word_id' => $prevWordId, 'contentclass_id' => $contentTypeId, 'contentclass_attribute_id' => $fieldTypeId, 'published' => $published, 'section_id' => $sectionId, 'identifier' => $identifier, 'integer_value' => $integerValue];
$query = $this->dbHandler->createInsertQuery();
$query->insertInto('ezsearch_object_word_link');
foreach ($assoc as $column => $value) {
$query->set($this->dbHandler->quoteColumn($column), $query->bindValue($value));
}
$stmt = $query->prepare();
$stmt->execute();
}
示例7: insertFieldDefinition
/**
* Inserts a $fieldDefinition for $typeId.
*
* @param mixed $typeId
* @param int $status
* @param \eZ\Publish\SPI\Persistence\Content\Type\FieldDefinition $fieldDefinition
* @param \eZ\Publish\Core\Persistence\Legacy\Content\StorageFieldDefinition $storageFieldDef
*
* @return mixed Field definition ID
*/
public function insertFieldDefinition($typeId, $status, FieldDefinition $fieldDefinition, StorageFieldDefinition $storageFieldDef)
{
$q = $this->dbHandler->createInsertQuery();
$q->insertInto($this->dbHandler->quoteTable('ezcontentclass_attribute'));
$q->set($this->dbHandler->quoteColumn('id'), isset($fieldDefinition->id) ? $q->bindValue($fieldDefinition->id, null, \PDO::PARAM_INT) : $this->dbHandler->getAutoIncrementValue('ezcontentclass_attribute', 'id'))->set($this->dbHandler->quoteColumn('contentclass_id'), $q->bindValue($typeId, null, \PDO::PARAM_INT))->set($this->dbHandler->quoteColumn('version'), $q->bindValue($status, null, \PDO::PARAM_INT));
$this->setCommonFieldColumns($q, $fieldDefinition, $storageFieldDef);
$q->prepare()->execute();
if (!isset($fieldDefinition->id)) {
return $this->dbHandler->lastInsertId($this->dbHandler->getSequenceName('ezcontentclass_attribute', 'id'));
}
return $fieldDefinition->id;
}
示例8: trashLocation
/**
* Sends a single location identified by given $locationId to the trash.
*
* The associated content object is left untouched.
*
* @param mixed $locationId
*
* @return bool
*/
public function trashLocation($locationId)
{
$locationRow = $this->getBasicNodeData($locationId);
/** @var $query \eZ\Publish\Core\Persistence\Database\InsertQuery */
$query = $this->handler->createInsertQuery();
$query->insertInto($this->handler->quoteTable('ezcontentobject_trash'));
unset($locationRow['contentobject_is_published']);
foreach ($locationRow as $key => $value) {
$query->set($key, $query->bindValue($value));
}
$query->prepare()->execute();
$this->removeLocation($locationRow['node_id']);
$this->setContentStatus($locationRow['contentobject_id'], ContentInfo::STATUS_ARCHIVED);
}
示例9: addPolicyLimitations
/**
* Adds limitations to an existing policy.
*
* @param int $policyId
* @param array $limitations
*/
public function addPolicyLimitations($policyId, array $limitations)
{
foreach ($limitations as $identifier => $values) {
$query = $this->handler->createInsertQuery();
$query->insertInto($this->handler->quoteTable('ezpolicy_limitation'))->set($this->handler->quoteColumn('id'), $this->handler->getAutoIncrementValue('ezpolicy_limitation', 'id'))->set($this->handler->quoteColumn('identifier'), $query->bindValue($identifier))->set($this->handler->quoteColumn('policy_id'), $query->bindValue($policyId, null, \PDO::PARAM_INT));
$query->prepare()->execute();
$limitationId = $this->handler->lastInsertId($this->handler->getSequenceName('ezpolicy_limitation', 'id'));
foreach ($values as $value) {
$query = $this->handler->createInsertQuery();
$query->insertInto($this->handler->quoteTable('ezpolicy_limitation_value'))->set($this->handler->quoteColumn('id'), $this->handler->getAutoIncrementValue('ezpolicy_limitation_value', 'id'))->set($this->handler->quoteColumn('value'), $query->bindValue($value))->set($this->handler->quoteColumn('limitation_id'), $query->bindValue($limitationId, null, \PDO::PARAM_INT));
$query->prepare()->execute();
}
}
}
示例10: getNextId
/**
* Returns next value for "id" column.
*
* @return mixed
*/
public function getNextId()
{
$sequence = $this->dbHandler->getSequenceName('ezurlalias_ml_incr', 'id');
/** @var $query \eZ\Publish\Core\Persistence\Database\InsertQuery */
$query = $this->dbHandler->createInsertQuery();
$query->insertInto($this->dbHandler->quoteTable("ezurlalias_ml_incr"));
// ezcDatabase does not abstract the "auto increment id"
// INSERT INTO ezurlalias_ml_incr VALUES(DEFAULT) is not an option due
// to this mysql bug: http://bugs.mysql.com/bug.php?id=42270
// as a result we are forced to check which database is currently used
// to generate the correct SQL query
// see https://jira.ez.no/browse/EZP-20652
if ($this->dbHandler->useSequences()) {
$query->set($this->dbHandler->quoteColumn("id"), "nextval('{$sequence}')");
} else {
$query->set($this->dbHandler->quoteColumn("id"), $query->bindValue(null, null, \PDO::PARAM_NULL));
}
$query->prepare()->execute();
return $this->dbHandler->lastInsertId($sequence);
}