user17
user17

Reputation: 383

How to get results from after stmnt->execute in doctrine2 symfony

I am using this:

$stmt = $this->getEntityManager()->getConnection()->prepare('SELECT * from tbl_users');
$stmt->execute();

How to get the results back in variables:

$stmt->getResults()

is not working

Upvotes: 1

Views: 513

Answers (1)

Vitalii Zurian
Vitalii Zurian

Reputation: 17976

You forgot about fetching result. fetchAll() could help you:

$stmt = $this->getEntityManager()
                 ->getConnection()
                 ->prepare('SELECT * from tbl_users');    
$stmt->execute();

$result = $stmt->fetchAll();

If you want to hydrate your TblUsers after fetching data - you can try to to next:

$tblUser = new TblUsers();
$tblUser->fromArray($result);

Upvotes: 2

Related Questions