本文整理汇总了PHP中eZ\Publish\Core\Persistence\Database\DatabaseHandler::useSequences方法的典型用法代码示例。如果您正苦于以下问题:PHP DatabaseHandler::useSequences方法的具体用法?PHP DatabaseHandler::useSequences怎么用?PHP DatabaseHandler::useSequences使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZ\Publish\Core\Persistence\Database\DatabaseHandler
的用法示例。
在下文中一共展示了DatabaseHandler::useSequences方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}