⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Has anyone worked with multi schemes of Postgres in GCE?



Cyn
  • profile picture
  • Member

Posted 26 August 2019 - 15:31 PM

Hi!.. 

I am trying to work with postgres schemes. Codeigniter is supported but Grocery Crud is broken by using other scheme than the public. Anyone knows anything about it? Thank you!!!

 


web-johnny
  • profile picture
  • Administrator
  • 1,166 posts

Posted 28 August 2019 - 12:28 PM

Hi!.. 

I am trying to work with postgres schemes. Codeigniter is supported but Grocery Crud is broken by using other scheme than the public. Anyone knows anything about it? Thank you!!!

Hello @Cyn,

 

You should need to manually add the correct driver for Postgre. More specifically:

 

return [
    'adapter' => [
        'driver' => 'Pdo_Pgsql',
        'database' => 'postgres',
        'username' => 'postgres',
        'password' => '',
        'charset' => 'utf8'
    ]
];

More specifically at Codeigniter with the current installation here you should change the function in your controller like this:

 

private function _getDbData() {
        $db = [];
        include(APPPATH . 'config/database.php');
        return [
            'adapter' => [
                'driver' => 'Pdo_Pgsql',
                'host'     => $db['default']['hostname'],
                'database' => $db['default']['database'],
                'username' => $db['default']['username'],
                'password' => $db['default']['password'],
                'charset' => 'utf8'
            ]
        ];
    }

and it will work for you.

 

Let me know if that worked for you.

 

Regards

Johnny


Cyn
  • profile picture
  • Member

Posted 28 August 2019 - 19:54 PM

Thank you John!

The change didn't work for me but this patch did work:

private function _getDbData() {
        $db = [];
        include(APPPATH . 'config/database.php');
        $this->db->query("set search_path = partes,public;"); // --> "partes" is the new schema
        return [
            'adapter' => [
                'driver' => 'Pgsql',

                'host'     => $db['default']['hostname'],
                'database' => $db['default']['database'],
                'username' => $db['default']['username'],
                'password' => $db['default']['password'],
                'charset' => 'utf8'
            ]
        ];

It is not so elegant but it works. Regards!