Hello,
I`m having difficulty running Grocery CRUD Enterprise with postgresql database.
While using version 2.3.7 I was able to run CRUD on table, but column search (and tbh any ajax operations) was not working.
After upgrade to 2.4.1 I am getting Internal Server error:
<h4>An uncaught Exception was encountered</h4>
<p>Type: Exception</p>
<p>Message: Table "" does not exist</p>
<p>Filename: MyAppAdress/application/libraries/GroceryCrudEnterprise/zendframework/zend-db/src/Metadata/Source/AbstractSource.php</p>
<p>Line Number: 124</p>
No data is presented.
My sample controller:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
// Add those two lines at the beginning of your controller
include(APPPATH . 'libraries/GroceryCrudEnterprise/autoload.php');
use GroceryCrud\Core\GroceryCrud;
Class Crud_test extends CI_Controller {
private function _getDbData() {
$db = [];
include(APPPATH . 'config/database.php');
return [
'adapter' => [
'driver' => 'Pgsql',
'host' => $db['default']['hostname'],
'database' => $db['default']['database'],
'username' => $db['default']['username'],
'password' => $db['default']['password'],
'port' => '5432',
'charset' => 'utf8'
]
];
}
private function _getGroceryCrudEnterprise($bootstrap = true, $jquery = true) {
$db = $this->_getDbData();
$config = include(APPPATH . 'config/gcrud-enterprise.php');
$groceryCrud = new GroceryCrud($config, $db);
return $groceryCrud;
}
// Your function at your controller
public function demo_set_model()
{
$crud = $this->_getGroceryCrudEnterprise();
$crud->setTable('my_table');
$crud->setSubject('my_table_subject', 'my_table_subject');
$crud->columns(['my_column']);
$output = $crud->render();
$this->_example_output($output);
}
function _example_output($output = null) {
if (isset($output->isJSONResponse) && $output->isJSONResponse) {
header('Content-Type: application/json; charset=utf-8');
echo $output->output;
exit;
}
$this->load->view('example.php',$output);
}
}
I tried different ways for input table name (including "schema"."my_table" etc) but with no result.
CRUD does connect to the database.
If I input non-existent table name the error message is slightly different (Table "wrong_table_name" does not exist - instead of empty "").
Do I have to use different driver? I tried 'Pdo_Pgsql' and 'Pgsql' so far.
I would highly appreciate any clues and ideas.
Also, I can always downgrade to 2.3.7 if there is any fix for column search errors.