Note that when using PGSQL_BOTH, numerically and associatively indexed fields are separate variables and treated as such:
<?php
$res = pg_query("Select 'foo' as bar");
$data = pg_fetch_array($res, 0, PGSQL_BOTH);
var_dump($data);
// Array(2)
// {
// [0] => string(3) "foo"
// ["bar"] => string(3) "foo"
// }
// This won't affect $data['bar']
$data[0] = 'bar';
var_dump($data);
// Array(2)
// {
// [0] => string(3) "bar"
// ["bar"] => string(3) "foo"
// }
?>
If you want to have reference binding between your numeric and associative indexes, you'll have to establish that yourself:
<?php
$result = pg_query("Select 'foo' as bar");
$data = pg_fetch_row($result);
// Establish references between column name/number
$from = $data;
foreach($from as $cx => $value)
{
$key = pg_field_name($result, $cx);
if (is_string($key)) $data[$key] =& $data[$cx];
}
var_dump($data);
// Array(2)
// {
// [0] => &string(3) "foo"
// ["bar"] => &string(3) "foo"
// }
// Note the reference binding between $data[0] and $data['bar']
$data[0] = 'baz';
var_dump($data);
// Array(2)
// {
// [0] => &string(3) "baz"
// ["bar"] => &string(3) "baz"
// }
?>