本文整理汇总了PHP中eZ\Publish\Core\Persistence\Database\DatabaseHandler::prepare方法的典型用法代码示例。如果您正苦于以下问题:PHP DatabaseHandler::prepare方法的具体用法?PHP DatabaseHandler::prepare怎么用?PHP DatabaseHandler::prepare使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZ\Publish\Core\Persistence\Database\DatabaseHandler
的用法示例。
在下文中一共展示了DatabaseHandler::prepare方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: insertObjectState
/**
* Inserts a new object state into database
*
* @param \eZ\Publish\SPI\Persistence\Content\ObjectState $objectState
* @param int $groupId
*/
public function insertObjectState(ObjectState $objectState, $groupId)
{
$query = $this->dbHandler->createSelectQuery();
$query->select($query->expr->max($this->dbHandler->quoteColumn('priority')))->from($this->dbHandler->quoteTable('ezcobj_state'))->where($query->expr->eq($this->dbHandler->quoteColumn('group_id'), $query->bindValue($groupId, null, \PDO::PARAM_INT)));
$statement = $query->prepare();
$statement->execute();
$maxPriority = $statement->fetchColumn();
$objectState->priority = $maxPriority === null ? 0 : (int) $maxPriority + 1;
$objectState->groupId = (int) $groupId;
$query = $this->dbHandler->createInsertQuery();
$query->insertInto($this->dbHandler->quoteTable('ezcobj_state'))->set($this->dbHandler->quoteColumn('id'), $this->dbHandler->getAutoIncrementValue('ezcobj_state', 'id'))->set($this->dbHandler->quoteColumn('group_id'), $query->bindValue($objectState->groupId, null, \PDO::PARAM_INT))->set($this->dbHandler->quoteColumn('default_language_id'), $query->bindValue($this->maskGenerator->generateLanguageIndicator($objectState->defaultLanguage, false), null, \PDO::PARAM_INT))->set($this->dbHandler->quoteColumn('identifier'), $query->bindValue($objectState->identifier))->set($this->dbHandler->quoteColumn('language_mask'), $query->bindValue($this->generateLanguageMask($objectState->languageCodes), null, \PDO::PARAM_INT))->set($this->dbHandler->quoteColumn('priority'), $query->bindValue($objectState->priority, null, \PDO::PARAM_INT));
$query->prepare()->execute();
$objectState->id = (int) $this->dbHandler->lastInsertId($this->dbHandler->getSequenceName('ezcobj_state', 'id'));
$this->insertObjectStateTranslations($objectState);
// If this is a first state in group, assign it to all content objects
if ($maxPriority === null) {
// @todo Hm... How do we perform this with query object?
$this->dbHandler->prepare("INSERT INTO ezcobj_state_link (contentobject_id, contentobject_state_id)\n SELECT id, {$objectState->id} FROM ezcontentobject")->execute();
}
}