Перейти к основному содержанию

ORM (Object Relational Mapping)

Пример кода ORM

$builder->select('u','e')
    ->leftJoin('u.emails', 'e')
    ->where('u.id = :id')
    ->setParameter(':id', $id);

$user = $builder->getQuery()->getOneOrNullResult();

Пример кода ORM native SQL

<?php
use Doctrine\ORM\Query\ResultSetMapping;

$rsm = new ResultSetMapping();
// build rsm here

$query = $entityManager->createNativeQuery('SELECT id, name, discr FROM users WHERE name = ?', $rsm);
$query->setParameter(1, 'romanb');

$users = $query->getResult();

 

book_url_ref