⚠ 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

Pdo PgSQL Error



coeb
  • profile picture
  • Member

Posted 26 June 2020 - 18:50 PM

I'm currently having trouble setting up a grocery crud site using a Postgre database. I've poked through every forum post and haven't found a solution. My database config file looks like

$db['default'] = array(
	'dsn' => 'pgsql:host=localhost;dbname=dbname',
	'hostname' => 'localhost',
	'username' => 'username',
	'password' => 'password',
	'database' => 'dbname',
	'dbdriver' => 'Pdo_Pgsql',
	'dbprefix' => '',
	'pconnect' => FALSE,
	'db_debug' => (ENVIRONMENT !== 'production'),
	'cache_on' => FALSE,
	'cachedir' => '',
	'char_set' => 'utf8',
	'dbcollat' => 'utf8_general_ci',
	'swap_pre' => '',
	'encrypt' => FALSE,
	'compress' => FALSE,
	'stricton' => FALSE,
	'failover' => array(),
	'save_queries' => TRUE,
	'port'=> 5432
);

My controller looks like

	function display(){		
			$crud = new grocery_CRUD();
			$crud->set_table('table_name');
			$crud->set_subject('Subject');
			$crud->columns(columns);
			$output = $crud->render();	
			$this->_GC_output($output);
	}

and I have verified that  the php postgre extension is working by using the ubuntu command php--info | grep PostgreSQL.

I think the issue I'm having falls in php.ini but there have been quite a lot of different ways it's configured depending on the forum post. Mine looks like:

extension=pdo_pgsql.so
;extension=php_pdo_sqlite
extension=pgsql.so

What is my php.ini file configured wrong?

Thanks.


egsolis
  • profile picture
  • Member

Posted 13 July 2020 - 00:30 AM

Follow de Example, add to your controller these functions

 

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'
            ]
        ];
    }


private function _getGroceryCrudEnterprise($bootstrap = true, $jquery = true) {
        $db = $this->_getDbData();
        $config = include(APPPATH . 'config/gcrud-enteprise.php');
        $groceryCrud = new GroceryCrud($config, $db);
        return $groceryCrud;
}

 

And in your function:

function display(){        
            $crud = $this->_getGroceryCrudEnterprise();

            $crud->set_table('table_name');
            $crud->set_subject('Subject');
            $crud->columns(columns);
            $output = $crud->render();    
            $this->_GC_output($output);
    }