Answer the question
In order to leave comments, you need to log in
Difference of native, without DQL queries?
Which of the 3 native queries to use, why?
$conn = $this->entityManager->getConnection();
$sql = '
SELECT * FROM users
ORDER BY created_at ASC
';
$stmt = $conn->prepare($sql);
$stmt->execute();
return $stmt->fetchAll();
$conn = $this->entityManager->getConnection();
$sql = '
SELECT * FROM users
ORDER BY created_at ASC
';
return $conn->query($sql)->fetchAll();
$query = $this->entityManager->createQuery(
'SELECT p
FROM App\Domain\User\Model\Entity\User p
ORDER BY p.createdAt ASC'
);
return $query->execute();
$sql = '
SELECT * FROM users p
ORDER BY p.created_at ASC
';
$stmt = $conn->prepare($sql);
$stmt->execute([]);
return $stmt->fetchAll();
$query = $this->entityManager->createNativeQuery(
'SELECT alias
FROM users alias'
, new ResultSetMapping());
return $query->getResult();
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question