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));
?>