Generate unique id - doctrine - symfony2

doctrine, php, symfony

Solution

As of version 2.3, you can just add the following annotations to your property:

/**
 * @ORM\Column(type="guid")
 * @ORM\Id
 * @ORM\GeneratedValue(strategy="UUID")
 */
protected $id;

Problem

I want to generate a unique ticket ID for my tickets. But how to let doctrine generate a unique id? ``` /** * @ORM\Column(name="id", type="integer") * @ORM\Id() * @ORM\GeneratedValue(strategy="AUTO") */ protected $id; ``` little more explain: - id must be 6 charters like: 678915 - id must be unique

Original source