I'm new to CI and GroceryCRUD. It looks great however after the basic installation nd verification I created the database tables, updated by database.php and cannot get the employees example to work. Here's the error and my config:
Fatal error: Uncaught exception 'Exception' with message 'The table name does not exist. Please check you database and try again.' in /Library/WebServer/Documents/application/libraries/Grocery_CRUD.php:4349 Stack trace: #0 /Library/WebServer/Documents/application/libraries/Grocery_CRUD.php(3875): grocery_CRUD->get_table() #1 /Library/WebServer/Documents/application/libraries/Grocery_CRUD.php(3891): grocery_CRUD->pre_render() #2 /Library/WebServer/Documents/application/controllers/main.php(27): grocery_CRUD->render() #3 [internal function]: Main->employees() #4 /Library/WebServer/Documents/system/core/CodeIgniter.php(359): call_user_func_array(Array, Array) #5 /Library/WebServer/Documents/index.php(202): require_once('/Library/WebSer...') #6 {main} thrown in /Library/WebServer/Documents/application/libraries/Grocery_CRUD.php on line 4349
My Configuration
Mac OSX 10.7.5
===============
database.php
===============
$active_group = 'default';
$active_record = TRUE;
$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'cruduser';
$db['default']['password'] = 'foo45bar';
$db['default']['database'] = 'crud';
$db['default']['dbdriver'] = 'mysql';
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = FALSE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = '';
$db['default']['char_set'] = 'utf8';
$db['default']['dbcollat'] = 'utf8_general_ci';
$db['default']['swap_pre'] = '';
$db['default']['autoinit'] = TRUE;
$db['default']['stricton'] = FALSE;
====================
The result of $this->db->list_tables()); in the main.php
====================
Welcome to the world of Codeigniter
Array
(
)
===================
SELECT of MySQL User table
===================
mysql> select host,user from mysql.user;
+-----------+----------+
| host | user |
+-----------+----------+
| % | cruduser |
| localhost | root |
+-----------+----------+
2 rows in set (0.00 sec)
mysql>
======================
SHOW databases in MySQL
======================
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| crud |
| mysql |
| performance_schema |
+--------------------+
4 rows in set (0.00 sec)
================
SHOW Tables in 'crud' database
================
mysql> show tables;
+----------------+
| Tables_in_crud |
+----------------+
| actor |
| category |
| customers |
| employees |
| film |
| film_actor |
| film_category |
| offices |
| orderdetails |
| orders |
| payments |
| productlines |
| products |
+----------------+
13 rows in set (0.00 sec)
===================
source to main.php
==================
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Main extends CI_Controller {
function __construct()
{
parent::__construct();
/* Standard Libraries of codeigniter are required */
$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
echo "<pre>";
print_r($this->db->list_tables());
die();
}
public function employees()
{
$this->grocery_crud->set_table('employees');
$output = $this->grocery_crud->render();
echo "<pre>";
print_r($output);
echo "</pre>";
die();
}
}