M
M
Mike Evstropov2016-07-08 19:26:57
symfony
Mike Evstropov, 2016-07-08 19:26:57

How to organize tree categories in Symfony 3?

Symfony 3.
There is a Category entity, it has id, name, title, body fields with demo lines.
To implement a nested structure, I'm trying to add two fields parent and pos .
For parent :

/**
     * @var int
     *
     * @ORM\Column(name="parent", type="smallint", nullable=false, unique=false)
     */

For pos :
/**
     * @var int
     *
     * @ORM\Column(name="pos", type="smallint", nullable=false, unique=true)
     * @ORM\GeneratedValue(strategy="AUTO")
     */

When updating, the following error occurs:
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '0' f  
  or key 'UNIQ_64C19C180D9E6AC'

I do not leave the feeling that because I do not. I would like to get advice on how best to organize the architecture of categories. It is not necessary to chew everything, it can be in general terms, so that it would be clear how it is right.
ps I found an article on Habré (2012), just on the topic (+ I use Sonata Admin Bundle), but Nested tree, it seems that it only works with SF2 Is it really possible to drop version 3?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Skobkin, 2016-07-08
@Aroused

like it only works with SF2 Is it possible to throw version 3?

So like or not working?
Well, there seems to be a problem in that many bundles that are widely used do not yet support versions 2.8 and 3.0+. For example, Sonata bundles do not yet fully support new versions. Therefore, it is really worth considering whether to take version 3 right now or wait.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question