Too Much Data with Var_Dump in Symfony2 Doctrine2

Too much data with var_dump in symfony2 doctrine2

Replace var_dump() with the debug method dump() provided by Doctrine Common.

\Doctrine\Common\Util\Debug::dump($user);

It works for single objects and Doctrine collections and should prevent browser displaying issues you are having.

Printing only the first level attributes in the hierarchy of a variable in PHP

You can use:

\Doctrine\Common\Util\Debug::dump($variable, 1);

Symfony2 and Doctrine 2 result data incorrectly returns an array of nulls

This problem was caused by the updating of doctrine/orm to version 2.5 from 2.4.x. There is a lot of BC breaks.

Downgrade your doctrine/orm to https://packagist.org/packages/doctrine/orm#v2.4.7 and the problem will go away. After knowing this is your issue, you need to rewrite your queries to satisfy any new requirements. I did see a note in there about MariaDB problem as well.

In fact, since I haven't tackled this fully yet myself, it might be as easy as regenerating the entities. I'm always hesitant when I do that....

Use advanced select in doctrine2/ symfony2

so i couldn't use

 $qb->select('a.id,' . $expr->quot(':counter', ':denominator') . 'as count')

instead i've changed name from 'count' to 'field' nad removed 'as'

$qb->select('a.id id,' . $expr->quot($counter, $denominator . ' field'))

i used: replace class and regexp

And it works. PROBLEM SOLVED

Iterating over doctrine collections takes too much memory

I would suggest to use the doctrine "batch processing" (http://doctrine-orm.readthedocs.org/en/latest/reference/batch-processing.html).

It allows you to handle a lot of data and to limit the php memory used. So in your case that would be something like this:

  $em = $this->doctrine->getManager();
// Gets 4000 entities
$queryEntities1 = $em->createQuery('select e from MyBundle:Entity1');
$iterableEntities1 = $queryEntities1->iterate();

foreach ($iterableEntities1 as $row)
{
$entity1 = $row[0];
// 200 entities under every entity1
foreach ($entity1->getCollection1() as $c)
{
// write into an xml
}
$em->detach($entity1);
}

Not tested but you may need to add another query for your collection! But this way your memory will be cleaned after every entity (not sure it'll be enough in your case but you can still try to add another iterable request for the collection's foreach).



Related Topics



Leave a reply



Submit