Jump to content


Has anyone worked with multi schemes of Postgres in GCE?

postgres schema

  • Please log in to reply
2 replies to this topic

#1 Cyn

Cyn

    Newbie

  • Members
  • Pip
  • 6 posts

Posted 26 August 2019 - 03: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!!!

 



#2 web-johnny

web-johnny

    grocery CRUD Author

  • Administrators
  • 1,099 posts
  • LocationLondon

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


Posted Image

#3 Cyn

Cyn

    Newbie

  • Members
  • Pip
  • 6 posts

Posted 28 August 2019 - 07: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!







Also tagged with one or more of these keywords: postgres, schema

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users