Skip to content
Advertisement

Convert PDO resultset to array of objects

I have a PHP class called Product:

JavaScript

And another class that get data from database:

JavaScript

How can I convert this PDO resultset ($rst) to an array of objects Product?

Advertisement

Answer

Use the PDO::FETCH_CLASS argument.

JavaScript

http://php.net/manual/en/pdostatement.fetchall.php

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement