Sign up ×
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them, it only takes a minute:

I've got a complex question, I hope you will help me.

I'm using Doctrine DBAL in my application because I would like to make it works in Postgres and Mysql.

The problem is that I want to switch over the 5 schemas that I have.

For example I would to do this thing :

  1. Action 1 --> Select schema 1

  2. Action 2 --> Make a SQL request like this : "SELECT * FROM users"

  3. Action 3 --> Select schema 2

  4. Action 4 --> Make an other SQL request like this "SELECT * FROM users"

What I don't want to do :

  1. Action 1 --> Make a SQL request like this : "SELECT * FROM schema1.users"

  2. Action 2 --> Make an other SQL request like this "SELECT * FROM schema2.users"

What I tried (but don't work =S):

    $connection->getConnection()->exec("SET SEARCH_PATH schema1");
    $stmt = $connection->getConnection()->executeQuery("SELECT * FROM users");

Is anyone have an idea how I can solve my problem ? I will be very thankful if you could bring me some help.

Thank you.

Freezer

share|improve this question

1 Answer 1

I found where the problem was.

I did a mistake with my code >_<

Here is the code that work :

$connection->getConnection()->exec("SET SEARCH_PATH TO schema1");
$stmt = $connection->getConnection()->executeQuery("SELECT * FROM users");

Thank you

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.