note 109543 deleted from function.pg-fetch-all by danbrown
| From: | danbrown@php.net | Date: | Mon, 30 Jul 2012 15:51:00 +0000 |
| Subject: | note 109543 deleted from function.pg-fetch-all by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-189485@lists.php.net to get a copy of this message | ||
Note Submitter: qeremy [atta] gmail [dotta] com
----
Getting db results as object.
<?php
$qry = pg_query("SELECT * FROM users");
$rows = array();
while ($fch = pg_fetch_object($qry)) {
$rows[] = $fch;
}
// or
$rows = array_map(function($a){
return (object) $a;
}, (array) pg_fetch_all($qry));