0

I'm trying to connect to a different schema in postgres Database

Actually i'm connecting succesfully to the 'public' one using this code in a file named dbconfig.php that i will include in my other php web pages

<?php

// Informations de connection
$host = 'vm-XXXX-XXXX';
$port = '5432';
$dbname2 = 'myData';
$user = 'postgres';
$password = 'postgres';

// Connecion to the  database

$dbconn = pg_connect("host=$host port=$port dbname=$dbname2 user=$user password=$password")
or die('impossible Connexion  : ' . pg_last_error());

?>

Now , i'm facing a problem to connect to a specific Schema named MyDataBaseSchema

I searched how to achieve that and i 've seen that there is a way out using :

SET search_path TO myschema

But i don't know how to use that in my code ?

Note that , i don't want to use the specific schema using this way

select * from MyDataBaseSchema.tableName 
  • See the linked answer for more details on what `search_path` actually is. If you want to set it for a single session, just pass the SQL you've shown to `pg_query` like you would any other SQL; there's nothing special about the fact that you're running it from PHP. – IMSoP May 10 '22 at 08:19

0 Answers0