Fetching all rows as Object with pdo php -


i know function fetchobject (http://www.php.net/manual/en/pdostatement.fetchobject.php) gives me next row object of specified class, want rows object of specified class, pdo has function or have manually???

thanks!!

you looking pdostatement::fetchall:

pdostatement::fetchall — returns array containing of result set rows

example usage:

$arr = $stmt->fetchall(pdo::fetch_class, $class_name, $constructor_args); 

if not need of objects in single array, find iterating through rows work well:

while ($obj = $stmt->fetchobject($class_name, $constructor_args)) {     // process $obj } 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -