Answer the question
In order to leave comments, you need to log in
How to specify that a field is autoincrement?
When using annotations on an entity, everything is simple:
/**
* @ORM\Id
* @ORM\GeneratedValue(strategy="SEQUENCE")
* @ORM\SequenceGenerator(sequenceName="id", initialValue=1)
* @ORM\Column(type="integer")
*/
private int $id;
<?php
/** @var ClassMetadata $metadata */
use Doctrine\Persistence\Mapping\ClassMetadata;
$metadata->mapField([
'id' => true,
'fieldName' => 'id',
'type' => 'integer',
]);
Answer the question
In order to leave comments, you need to log in
Found in code:
$metadata->setIdGeneratorType($metadata::GENERATOR_TYPE_AUTO);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question