grocery-crud icon indicating copy to clipboard operation
grocery-crud copied to clipboard

Issue Installing

Open dziegler991 opened this issue 6 years ago • 4 comments

Hi all,

I am having a bit of trouble installing Grocery CRUD. It is throwing this error after following the basic steps to get it working.

An uncaught Exception was encountered Type: Error

Message: Cannot call constructor

Filename: /var/www/html/CodeIgniter/application/models/Grocery_crud_model.php

Line Number: 40

Backtrace:

File: /var/www/html/CodeIgniter/application/libraries/Grocery_CRUD.php Line: 484 Function: model

File: /var/www/html/CodeIgniter/application/libraries/Grocery_CRUD.php Line: 4607 Function: set_default_Model

File: /var/www/html/CodeIgniter/application/libraries/Grocery_CRUD.php Line: 4625 Function: pre_render

File: /var/www/html/CodeIgniter/application/controllers/Main.php Line: 27 Function: render

File: /var/www/html/CodeIgniter/index.php Line: 308 Function: require_once

The Main.php file looks like this:

<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
 
class Main extends CI_Controller {
 
function __construct()
{
        parent::__construct();
 
$this->load->database();
$this->load->helper('url');
/* ------------------ */ 
 
$this->load->library('grocery_CRUD');
 
}
 
public function index()
{
echo "<h1>Welcome to the world of Codeigniter</h1>";//Just an example to ensure that we get into the function
die();
}
 
public function ddtracker()
{
$crud = new grocery_CRUD();
$crud->set_table('ddtracker');
$output = $this->grocery_crud->render();
 
echo "<pre>";
print_r($output);
echo "</pre>";
die();
}
} 
/* End of file Main.php */
/* Location: ./application/controllers/Main.php */

dziegler991 avatar Jul 20 '18 19:07 dziegler991

Note: this is running on php7.2 and apache2.4.x.

dziegler991 avatar Jul 20 '18 19:07 dziegler991

Use first letter in upercase to class name.

Try :

$crud = new Grocery_CRUD();

instead of :

$crud = new grocery_CRUD();

bvrignaud avatar Jul 23 '18 09:07 bvrignaud

Unfortunately that didn't change anything

dziegler991 avatar Jul 23 '18 16:07 dziegler991

Comment out the lines from Grocery_crud_model.php file

// // function __construct() // { // // parent::__construct(); // } https://github.com/bcit-ci/CodeIgniter/commit/c45caeac4f45b83fbb3655f62638ebcf913981c8

ADavidBarros avatar Oct 20 '18 14:10 ADavidBarros