I am working with PHP and PDO connecting to a postgresql database, I have a doubt, since something that I do not expect is happening.
$pdo = new PDO('pgsql:dbname=db_pdo_postgresql;
host=localhost;', 'juan_postgres', 'root');
foreach($pdo->query('SELECT * from user') as $fila) {
if($fila==null){
echo "Vacio";
}else{
echo "<pre>";
print_r($fila);
}
}
$pdo = null;
That's the code, and the result is this.
Array
(
[current_user] => juan_postgres
[0] => juan_postgres
)
the user returns me practically. and if I change the query
SELEC * from public.user
He returns me.
Array
(
[ID] => 1
[0] => 1
[name] => Laura
[1] => Laura
)
Array
(
[ID] => 2
[0] => 2
[name] => Juan
[1] => Juan
)
The case, is that I do not want you to be adding the public prefix, in each sql statement. since when changing BD, you would have to modify the SQL. and that would not be the case, for the use of PDO. thanks