當前位置: 首頁>>代碼示例>>PHP>>正文


PHP DatabaseHandler::prepare方法代碼示例

本文整理匯總了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();
     }
 }
開發者ID:CG77,項目名稱:ezpublish-kernel,代碼行數:26,代碼來源:DoctrineDatabase.php


注:本文中的eZ\Publish\Core\Persistence\Database\DatabaseHandler::prepare方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。