Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

getResult() method Doctrine

What is the format of the array returned using the getResult() method in the following example, using Doctrine and Symfony2:

$query = $this->_em->createQuery('SELECT p.id, p.nameProduct FROM ArkiglassProductBundle:Product p');
        return $query->getResult();

And I would like to know how to access each case and print every row.

like image 255
BaHar AyØub Avatar asked Jan 29 '26 02:01

BaHar AyØub


1 Answers

<?php
$query = $em->createQuery('SELECT u.username, u.name FROM CmsUser u');
$users = $query->getResults(); // array of CmsUser username and name values
echo $users[0]['username'];

taken from the doctrine documentation

like image 73
snyx Avatar answered Jan 30 '26 20:01

snyx



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!