⚠ 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

Incorrect table name



rolin

rolin
  • profile picture
  • Member

Posted 27 July 2013 - 14:07 PM

Hello,

 

I just installed code igniter and grocery crud. I wrote the example page, i.e. 

<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');




class Mytest extends CI_Controller {


    function __construct()
    {
        parent::__construct();




        /* Standard Libraries */
        $this->load->database();
        $this->load->helper('url');


        /* ------------------ */    


        $this->load->library('grocery_CRUD');    
    }


    function _example_output($output = null)


    {
        $this->load->view('example.php',$output);    
    }


    function offices()


    {
        
        $output = $this->grocery_crud->render();
        
        $this->_example_output($output);


    }




}

It returns me an error:

A Database Error Occurred

Error Number: 1103

Incorrect table name ''

SHOW COLUMNS FROM ``

Filename: D:\wamp\www\codeigniter\system\database\DB_driver.php

Line Number: 330

 

The dataset is well set, I created 2 tables into it. Shall I notice the existing tables/columns ? Can't that be automatic ?

 


davidoster

davidoster
  • profile picture
  • Member

Posted 27 July 2013 - 14:34 PM

Hello and welcome to the forums [member=rolin].

When you don't specify the table using the set_table the Grocery CRUD library tries to find a table named by the name of your controller's function, e.g. offices.

If you have this table but for some strange reason it fails then just before the render include the,

$this->grocery_crud->set_table('offices');

 

Let us know if this resolves your issue.

Make sure you edit the database.php under application/config with your database server settings.


CharleSven

CharleSven
  • profile picture
  • Member

Posted 26 June 2015 - 07:16 AM

This problem also happens also to me. Since I am using table prefix in my 

database.php

 config for example 

'tb_'

instead of writing for database table name tb_it_tasks    

$crud->set_table('tb_it_tasks');

I only write like this    

$crud->set_table('it_tasks');

Works like a charm.