1

Is there a way to specify the schema to use with PHP's db2_connect method? Apparently it connects to the default schema, though it seems like there should be an option to specify schema in the connect string.

user101289
  • 9,888
  • 15
  • 81
  • 148
  • you connect to a db not a schema. can you add some details of what your trying to accomplish –  Oct 13 '15 at 19:33
  • @Dagon-- then after you connect, you'd set schema as a separate command? – user101289 Oct 13 '15 at 19:37
  • correct, there's no connect db + select schema in one function. but as below you can defult –  Oct 13 '15 at 20:01

2 Answers2

1

You cannot do this using db2_connect(), however, there are other options.

  1. Issue the set schema statement:

    db2_exec($yourconnection, 'SET SCHEMA WHATEVER')

  2. Set the default schema in the db2cli.ini file using the CurrentSchema keyword.

  3. Similarly, use CurrentSchema parameter in the db2dsdriver.cfg file.

Note that the latter two methods will affect all connections, including those made by other CLI/ODBC applications on that machine.

mustaccio
  • 18,234
  • 16
  • 48
  • 57
0

Take a look at my answer on SO here: https://stackoverflow.com/a/31082570/652519

It might help get things setup and configured correctly. There is an option in the odbc.ini file called Default Libraries. I've never had the need to change this, but this may be what you're looking for.

There's also an option for the database. In the above referenced answer, the database value in the odbc.ini file is blank, which I would assume can be changed. Again, I haven't had a need to change it, so you can tinker with it to test.

Community
  • 1
  • 1
Michael
  • 2,016
  • 5
  • 35
  • 51