mhndev / doctrine-repository
doctrine repository with simple queries inspired by eloquent
dev-develop
2016-07-02 23:52 UTC
Requires
- doctrine/orm: ^2.4.8
This package is auto-updated.
Last update: 2024-10-06 09:12:51 UTC
README
this package is for whom suffer from working with doctrine like me. for whom to like working with Eloquent ORM.
this package's intention is to help you to enjoy working with models and repositories and query the database as easy as possible.
sample usage :
every repository should extend
mhndev\doctrineRepository\AbstractDoctrineRepository
instead of
Doctrine\ORM\EntityRepository
so my UserRepository should look like :
namespace UserBundle\Repository; use mhndev\doctrineRepository\AbstractDoctrineRepository; /** * UserRepository * * This class was generated by the Doctrine ORM. Add your own custom * repository methods below. */ class UserRepository extends AbstractDoctrineRepository { }
for example in your action controller you can do the following. consider that here I have my UserRepository as an dependency in my UserController.
$userArray = $this->repository->findOneById(1, false); $userObject = $this->repository->findOneById(1); $users = $this->repository->where('name','ab', 'like')->where('enable', 1)->whereIn('status',['public','private'])->all();