I have the problem, that I have two controllers. One is a restful controller which only handles json data and returns a JsonModel, and the other one is a default controller which returns a ViewModel Now I have the problem, that my method only returns an array of entities, which is correct for the default cont…
Tag: doctrine-orm
How to get Doctrine to log queries in Symfony2
I’m pretty new to Symfony2, and I’m looking for a way to log SQL queries (including timings) to the same log file as the rest of my application. From what I can determine from the documentation this should all work out of the box, but after a few hours of trying I can’t figure out what IR…
Symfony2 persist form collections with Doctrine UNIQUE INDEX and ORDER BY?
I have a User entity that has a collection of List Items associated with it. Each List Item entity also references another entity, Topic. I have setup a UNIQUE constraint on the List Item table that …
Difference between call flush() inside foreach loop or outside it, which one to use?
I’m having this doubt for a while but now is time to ask around it. See the code below and having a huge items in $someVar, for example 200 items: Both calls will do the same? meaning delete records from the DB? At performance level, which one is best to use? (Doctrine behaves as a memory killer sometim…
Doctrine : Default value on joinColumn field
New to symfony2 and Doctrine. How can I set a default value to the field foo_id (which is a reference on Foo table) to point on the ID 1 of the Foo table (which exists in all cases) ? I tried a lot of things without success : Set default value to ID 1 in the constructor of Foo Perform
Memory leak when executing Doctrine query in loop
I’m having trouble in locating the cause for a memory leak in my script. I have a simple repository method which increments a ‘count’ column in my entity by X amount: Problem is, if I call this in a loop the memory usage balloons on every iteration: What am I missing here? I’ve tried -…
Access Command OutputInterface within a Doctrine Fixtures Load
I’m generating a huge amount of data fixtures using the awesome Faker Library, also using lorempixel.com to have some random images in my Symfony2 project. This takes some time (currently ~ 10 Minutes), so I was wondering if it is possible to access the Command OutputInterface somehow through the contai…
Doctrine2 find by value in field array
i wonder if there is a way to search for a document field looking like : /** * @var array * * @ORMColumn(name=”tags”, type=”array”, nullable=true) */ private $tags; which in database looks …
How to use Master/Slave doctrine2 configurations from Symfony2 Console commands
I’m using the Doctrine2 master/slave configuration in Symfony2 to scale my application across a single master database and several read-only (replicated) slaves. This works perfectly from within my application and Doctrine2 sensibly uses the slave for read-only queries and the master for write operation…
How can I get ID of entity in form type?
I have form type for build form of category: class CategoryType extends AbstractType { /** * @param FormBuilderInterface $builder * @param array $options */ public function …