eZ\Publish\Core\Persistence\Database\DatabaseHandler::useSequences PHP Метод

useSequences() публичный Метод

Check for sequence based driver or not.
public useSequences ( ) : boolean
Результат boolean
    public function useSequences();

Usage Example

 /**
  * 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);
 }