本文整理匯總了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();
}
}