lynx / lynx
This package is abandoned and no longer maintained.
No replacement package was suggested.
Awesome Mapper on top of DBAL/Doctrine2
0.2.1
2016-02-10 15:33 UTC
Requires
- php: >=5.5
- doctrine/cache: ~1.6.0
- doctrine/collections: ~1.1
- doctrine/common: ~2.5
- doctrine/dbal: ~2.5.2
- doctrine/inflector: ~1.1
- doctrine/orm: ~2.5.0
Requires (Dev)
- phpunit/phpunit: ~4.8.18
- squizlabs/php_codesniffer: ~2.3.4
This package is auto-updated.
Last update: 2020-12-28 22:33:36 UTC
README
An awesome Mapper on top of Doctrine 2 components
How to work?
First you need to setup EntityManager ($em) :
$configuration = new Configuration(); $configuration->setResultCacheImpl($di->getCache()); $configuration->setMetadataDriverImpl( new \Doctrine\ORM\Mapping\Driver\AnnotationDriver( new AnnotationReader(), realpath(APP_ROOT_PATH . '/src/BlaBla/User/Model/') ) ); $configuration->setMetadataCacheImpl( new \Doctrine\Common\Cache\ApcCache() ); $em = new \Lynx\EntityManager( $di->getDb(), $configuration );
Working with repository
You can get a Repository
for Model
by using method getRepository
from EntityManager
:
$repository = $em->getRepository(User::class);
For example, you can get one row by using:
$repository = $em->getRepository(User::class); /** User|null $user */ $user = $repository->findOne(1);
You can count all rows from table:
$repository = $em->getRepository(User::class); $count = $repository->count();
Testing
PostgresSQL
sudo docker run --name lynx-test -p 5432:5432 -e POSTGRES_PASSWORD= -d postgres
psql -p 5432 -h 127.0.0.1 -U postgres -c 'create database lynx_test;'
psql -p 5432 -h 127.0.0.1 -U postgres -d lynx_test -f tests/schemas/pqsql/lynx_test.sql
LICENSE
MIT