I deleted a property (teaser) from an enitiy (sale). I used the CLi to update the database & entites:
$ php app/console doctrine:schema:update --complete --force
$ php app/console doctrine:generate:entities Our --no-backup
$ php app/console doctrine:cache:clear-metadata
$ php app/console doctrine:cache:clear-result
And i cleared the cache:
$ php app/console cache:clear --no-optional-warmers --no-warmup
Now i have a query created by query builder:
$qb = $this->createQueryBuilder('s');
$q = $qb
->select('s.id')
->leftJoin('s.bills','b')
->where('b.paid = true')
->getQuery()
->getResult();
This throws an error becuas eit generates a select statement that includes the old property:
Column not found: 1054 Unknown column 's0_.teaser' in 'field list'
I tried to understand how Doctrine executes the query but failed to find the source of the problem. Does anyone have any clues?
UPDATE: I took the DQL from the query, generated by the querybuilder and then used that to create a new Query. Same Error. Then i changed one word in the DQL from uppercae to lowercase (LEFT is now Left) and that one executed just fine.
$q = $this->getEntityManager()
->createQuery('SELECT s,b FROM Our\BuyBundle\Entity\Sale s Left JOIN s.bills b WHERE s.id IN (:randomIds)')
->setParameter('randomIds', $allSaleIds);
So it seems the DQL Statement is cached somewhere, Using the DQL as a hash to get the corresponding SQL Statement. I still can't quite figure out where and how to clear that cached Information. Especially given the fact that i deleted all content in the app/cache folder as well.
UPDATE2: Found the Solution. Had to clear the APC Cache manually since the console can't do that. So the Solution would be:
$ php app/console doctrine:cache:clear-query
And if that doesn't work, clear your APC Cache.
My Problem was the APC Cache.
I could not clear the query-cache in CLI (app/console) since the console can't (or is not allowed to) clear the APC Cache. So i had to clear the APC Cache manually.
Solution is:
$ php app/console doctrine:cache:clear-result
And if that doesn't work, clear the APC Cache (or whatever cache you use) manually.