Jump to content


Pdo PgSQL Error


  • Please log in to reply
1 reply to this topic

#1 coeb

coeb

    Newbie

  • Members
  • Pip
  • 2 posts

Posted 26 June 2020 - 06: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.



#2 egsolis

egsolis

    Newbie

  • Members
  • Pip
  • 9 posts
  • LocationMexico

Posted 13 July 2020 - 12: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);
    }





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users