This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace MyBundle\Entity; | |
use Doctrine\ORM\Mapping as ORM; | |
use Symfony\Component\Validator\Constraints as Assert; | |
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; | |
/** | |
* MyEntity. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace MyBundle\Entity; | |
use Doctrine\ORM\Mapping as ORM; | |
/** | |
* RecentSearch | |
* | |
* @ORM\Table("recent_search") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace MyBundle\Repository; | |
use MyBundle\Entity\Customer; | |
use Doctrine\ORM\EntityRepository; | |
class RecentSearchRepository extends EntityRepository | |
{ | |
public function findRecentByUser(Customer $user) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT l.*, MAX(s.sale_ts) FROM location AS `l` LEFT JOIN sales AS `s` ON l.id = s.location_id GROUP BY(s.location_id); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Trying to emulate | |
// SELECT l.*, MAX(s.sale_ts) FROM location AS `l` LEFT JOIN sales AS `s` ON l.id = s.location_id GROUP BY(s.location_id); | |
// But the group selects the last result. | |
$qb = $this->createQueryBuilder('l') | |
->leftJoin('l.sales', 's') | |
->where('l.is_active = 1') | |
->orderBy('l.id', 'ASC') | |
->addOrderBy('s.sale_ts', 'DESC') | |
->groupBy('l.id'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$qb = $this->createQueryBuilder('l') | |
->leftJoin('l.sales', 's') | |
->where('l.is_active = 1') | |
->andWhere('s.sale_ts = (SELECT MAX(s2.sale_ts) FROM MyBundle:Sale s2 WHERE s2.location = l)') | |
->orderBy('l.id', 'ASC'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$qb = $this->createQueryBuilder('l') | |
->select('l, c') | |
->join('l.country', 'c') | |
->where($expr->in('l.id', '?1')) | |
->setParameter(1, $ids); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mybundle.repository.mymodelrepo: | |
class: MyBundle\Repository\MyModelRepository | |
calls: | |
- [ unpack, [@=service('snc_redis.default').get('MyModel')] ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace MyBundle\Form\Type; | |
use Symfony\Component\DependencyInjection\ContainerAwareInterface; | |
use Symfony\Component\Form\AbstractType; | |
use Symfony\Component\Form\FormBuilderInterface; | |
use Symfony\Component\Validator\Constraints as Assert; | |
class MyFormType extends AbstractType implements ContainerAwareInterface |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Parent{ | |
private static $attribute; | |
public getAttribute(){ | |
return self::$attribute; | |
} | |
} |