0

I use Doctrine DBAL v2.5.0 and I would like to perform a simple update statement. In the documentation it is written that I should use the method executeUpdate() (http://doctrine-dbal.readthedocs.org/en/latest/reference/data-retrieval-and-manipulation.html#executeupdate) for that. But in the source code this method has the annotation @internal. Because of that I am not sure whether this method should be used from non-library code or not. Should I?

Daniel Mecke
  • 984
  • 10
  • 19

1 Answers1

0

It seems that you have to use the executeUpdate() method on the doctrine service and not on the entity manager.

$this->container->get('doctrine.orm.entity_manager')->getConnection()->executeUpdate($query); gives a warning in my IDE that executeUpdate() is @internal.

$this->container->get('doctrine')->getConnection()->executeUpdate($query); or in a controller $this->getDoctrine()->getConnection()->executeUpdate($query); does not give any warning.

With other words: You want to call the executeUpdate() method on \Doctrine\Bundle\DoctrineBundle\Registry class instead of the \Doctrine\ORM\EntityManager class

P.D. Maybe I should mention that I am using Doctrine in conjunction with Symfony2.

Jorgo Miridis
  • 37
  • 1
  • 6
  • Thanks a lot for your answer! But I am not sure about it: `$this->container->get('doctrine.orm.entity_manager')` gives a `Doctrine\ORM\EntityManager` object and `$this->container->get('doctrine')` a `Doctrine\Bundle\DoctrineBundle\Registry` object. But when I call `getConnection()` I get a `Doctrine\DBAL\Connection` in both cases, so I end up with the same problem. – Daniel Mecke Jan 12 '15 at 08:20