0

My application is using CodeIgniter 2 and want to connect it to postgresql. Database name is tirta and schema is wening. My problem is it always connect to schema public. How can I fix it?

Here is my database configuration:

$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'postgres';
$db['default']['password'] = 'mypass';
$db['default']['database'] = 'tirta';
$db['default']['schema'] = 'wening';
$db['default']['dbdriver'] = 'postgre';
Abaij
  • 853
  • 2
  • 18
  • 34
  • You could change the [search path](https://www.postgresql.org/docs/current/ddl-schemas.html#DDL-SCHEMAS-PATH) for your user in Postgres –  Jan 18 '19 at 10:02
  • Thanks for pointing it out but have no idea how to implement it in my script – Abaij Jan 18 '19 at 15:21

1 Answers1

0

You can just include that schema in the search path.

If you can use a "setup statement" that is run after the connection has been established, you can use:

set search_path=wening,public;

Another option is to permanently change the user to use that search path (regardless on how or from which tool that user connects):

alter user postgres
  set search_path = wening,public;

Unrelated, but: it is a bad idea to use the superuser as the application user.

  • i did it and search_path has changed to `wening,public` but still the application refers to `public` schema. is there something to change in the codeigniter configuration? – Abaij Jan 20 '19 at 12:34