Introduction
Objectiphy is a simple data mapper ORM - inspired by (and somewhat compatible with) the Doctrine project, with the aim of being easy to learn, intuitive, and flexible.
use Objectiphy\Objectiphy\Factory\RepositoryFactory;
use MyProject\Contact;
$pdo = new \PDO(
'mysql:host=localhost;dbname=test',
getenv('DB_USER'),
getenv('DB_PASS')
);
$factory = new RepositoryFactory($pdo);
$repository = $factory->createRepository(Contact::class);// Load all staff in Sales department:
$criteria = ['department.name' => 'Sales'];
$contacts = $repository->findBy($criteria);// Get just the name for permanent staff in Sales and
// Finance who have a car (even if the Contact entity
// does not have a vehicle property)
$criteria = ['departments' => ['Sales', 'Finance']];
$query = QB::create()
->select('firstName', 'lastName')
->from(Contact::class)
->innerJoin(Vehicle::class, 'v')
->on('id', '=', 'v.ownerContactId')
->and('v.type', '=', 'car')
->where('department.name', 'IN', ':departments')
->and('isPermanent', '=', true)
->buildSelectQuery($criteria);
$contacts = $repository->findBy($query);Features
Last updated