/**
  * Inserts a $fieldDefinition for $typeId.
  *
  * @param mixed $typeId
  * @param int $status
  * @param \eZ\Publish\SPI\Persistence\Content\Type\FieldDefinition $fieldDefinition
  * @param \eZ\Publish\Core\Persistence\Legacy\Content\StorageFieldDefinition $storageFieldDef
  *
  * @return mixed Field definition ID
  */
 public function insertFieldDefinition($typeId, $status, FieldDefinition $fieldDefinition, StorageFieldDefinition $storageFieldDef)
 {
     $q = $this->dbHandler->createInsertQuery();
     $q->insertInto($this->dbHandler->quoteTable('ezcontentclass_attribute'));
     $q->set($this->dbHandler->quoteColumn('id'), isset($fieldDefinition->id) ? $q->bindValue($fieldDefinition->id, null, \PDO::PARAM_INT) : $this->dbHandler->getAutoIncrementValue('ezcontentclass_attribute', 'id'))->set($this->dbHandler->quoteColumn('contentclass_id'), $q->bindValue($typeId, null, \PDO::PARAM_INT))->set($this->dbHandler->quoteColumn('version'), $q->bindValue($status, null, \PDO::PARAM_INT));
     $this->setCommonFieldColumns($q, $fieldDefinition, $storageFieldDef);
     $q->prepare()->execute();
     if (!isset($fieldDefinition->id)) {
         return $this->dbHandler->lastInsertId($this->dbHandler->getSequenceName('ezcontentclass_attribute', 'id'));
     }
     return $fieldDefinition->id;
 }
 /**
  * Returns next value for "id" column.
  *
  * @return mixed
  */
 public function getNextId()
 {
     $sequence = $this->dbHandler->getSequenceName('ezurlalias_ml_incr', 'id');
     /** @var $query \ezcQueryInsert */
     $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->getName() === 'pgsql') {
         $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);
 }