当前位置: 首页>>代码示例>>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;未经允许,请勿转载。