Doctrine’s findAll method returns the same id on all lines

Asked

Viewed 131 times

0

I am doing a search that returns all the data of my Entity.

,

it happens that it returns me all the data but with the same id, but I checked the database the ids are different.

.

$entityManager->clear();
        print_r($entityManager->getRepository('models\AlarmesNcc')->findAll());
        $entityManager->flush();

returning

Array
(
    [0] => models\AlarmesNcc Object
        (
            [id:models\AlarmesNcc:private] => 1 /aqui nesta linha
            [criated:models\AlarmesNcc:private] => dd
            [severity:models\AlarmesNcc:private] => ssss
            [deviceService:models\AlarmesNcc:private] => ss
            [details:models\AlarmesNcc:private] => sss
            [usuario:models\AlarmesNcc:private] => 1
        )

    [1] => models\AlarmesNcc Object
        (
            [id:models\AlarmesNcc:private] => 1 /aqui nesta linha
            [criated:models\AlarmesNcc:private] => dd
            [severity:models\AlarmesNcc:private] => ssss
            [deviceService:models\AlarmesNcc:private] => ss
            [details:models\AlarmesNcc:private] => sss
            [usuario:models\AlarmesNcc:private] => 1
        )

)

1 answer

1

I solved it, the problem was in the Doctrine notes

was this way

/**
     * @var boolean
     *
     * @ORM\Column(name="id", type="boolean", nullable=false)
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="IDENTITY")
     */

because when I generated the Annotation to my table with field id was of type tynint

I changed the id in the table to int and changed the Annotation doing this

/**
     * @var integer
     *
     * @ORM\Column(name="id", type="integer", nullable=false)
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="IDENTITY")
     */

worked perfectly

Browser other questions tagged

You are not signed in. Login or sign up in order to post.