doctrine
Expression mysql NOW() in Doctrine QueryBuilder
In Doctrine2 you have to use one of the following instead of NOW(). This: CURRENT_TIMESTAMP() Or: … createQuery(…’WHERE x.date = :now’) ->setParameter(‘now’, new \DateTime(‘now’)) … If you want only time or only date use one of those: CURRENT_TIME() and CURRENT_DATE() Documentation can be found here.
Generating Entity Getters and Setters in Symfony / Doctrine ORM
try : php app/console doctrine:generate:entities EvrHomeBundle:Article If you are using symfony 3.0 or higher then substitue app with bin: php bin/console doctrine:generate:entities EvrHomeBundle:Article If you are using symfony 4+ then : php bin/console make:entity –regenerate
Doctrine Batch Processing Iterate High Memory Usage
Batch processing with doctrine is trickier than it seems, even with the help of iterate() and IterableResult. Just as you expected greatest benefit of IterableResult is that it does not load all of the elements into memory, and the second benefit is that it doesn’t hold references to the entities you load, thus IterableResult doesn’t … Read more
Limiting a doctrine query with a fetch-joined collection?
Paginate was merged with doctrine 2.2 And the new symfony2 release 2.0.10 is compatible with. Now use it like that //use Doctrine paginator use Doctrine\ORM\Tools\Pagination\Paginator; Write your query then call results like that. $query->setMaxResults($limit); $query->setFirstResult($offset); $results = new Paginator($query, $fetchJoin = true); Hope this will help you. Note: If you are using SF2 2.0.10, you … Read more
how to sort an entity’s arrayCollection in symfony2
You should be able to use the @ORM\OrderBy statement which allows you to specify columns to order collections on: /** * @ORM\OneToMany(targetEntity=”BizTV\ContentManagementBundle\Entity\Content”, mappedBy=”container”) * @ORM\OrderBy({“sort_order” = “ASC”}) */ private $content; In fact this may be a duplicate of How to OrderBy on OneToMany/ManyToOne Edit Checking for implementation advice it appears that you must fetch the … Read more