managlea / entity-manager
dev-master / 0.0.x-dev
2016-03-29 16:28 UTC
Requires
- php: >=7.0
- doctrine/orm: 2.5.*
- symfony/dependency-injection: ~3.0
- symfony/yaml: ~3.0
Requires (Dev)
- codeclimate/php-test-reporter: dev-master as 0.0.1
- phpunit/phpunit: ~5.2
This package is not auto-updated.
Last update: 2024-04-27 15:31:39 UTC
README
Wrapped on top of different database connectors to provide general interface. Currently supports only Doctrine ORM.
##Basic usage (DoctrineEntityManager):
// Create directly $em = new DoctrineEntityManager($entityManager); // Create using factory (recommended) $em = new EntityManagerFactory($containerBuilder)->create('doctrine_entity_manager'); // Get single entity $entity = $em->get('Entities\Product', 1); // Get single entity (with additional criterias) $entity = $em->get('Entities\Product', 1, array('user_id' => 2)); // Get collection $entityCollection = $em->getCollection('Entities\Product'); // Create new entity $newEntity = $em->create('Entities\Product', array('name' => 'foo')); // Update newly created entity $updatedEntity = $em->update('Entities\Product', $newEntity->getId(), array('name' => 'bar')); // Delete update entity $em->delete('Entities\Product', $updatedEntity->getId());
As all existing Doctrine functionality is left intact you are also able to use all Doctrine ORM build in methods:
$em = new DoctrineEntityManager($entityManager); $user = new User; $user->setName('Mr.Right'); $em->persist($user); $em->flush();