scoumbourdis / grocery-crud

Grocery CRUD is a PHP Codeigniter Framework library that creates a full functional CRUD system without the requirement of extra customisation to the JavaScripts or the CSS to do it so.
http://www.grocerycrud.com
GNU General Public License v3.0
1.01k stars 472 forks source link

Prefix error #66

Open TheDarkITA opened 12 years ago

TheDarkITA commented 12 years ago

$crud->set_table('tdi_config');

Generate this error:

Query failed: Unknown table 'tdi_tdi_config' Actual query: SELECT tdi_tdi_config.* FROM (tdi_config) LIMIT 25

ibrahimyu commented 12 years ago

it is possible that GC has included the prefix automatically. have you tried this?

$crud->set_table('config');

TheDarkITA commented 12 years ago

Yes, generate this error:

Error Number: 1146

Table 'thedarkita_db1.config' doesn't exist

SHOW COLUMNS FROM config

gralosky commented 12 years ago

will it ever done ? :)

SethArchambault commented 11 years ago

I too an getting this error.. Using

$crud->set_table('bf_schedule');

gives me:

A Database Error Occurred
Error Number: 1064

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.* FROM (`bf_schedule`)' at line 1

SELECT bf_`bf_schedule`.* FROM (`bf_schedule`)

Filename: /home/sitename/prod/models/grocery_crud_model.php

Line Number: 87
kaerte commented 11 years ago

I was having the same issue. Ci is adding db prefix automatically and I come up with a quick hack to get it working without trowing these errors.

in grocery crud model constructor add

$this->db->set_dbprefix('');

this will clear prefix that CI uses for all grocery crud db functions, but you will have to add prefix manually in your controller. e.g. $crud->set_table('prefix_table');

MikeyBeLike commented 8 years ago

@kaerte thanks, had to use this method too.

Nihilistik commented 8 years ago

If the problem is CodeIgniter dbprefix management, why not to focus on that part? I've found the code where CI3 concat the dbprefix with the user query string, and i've been able to patch it. You can find it here: https://github.com/Nihilistik/Grocery_CRUD-CodeIgniter-dbprefix-bug

Maybe it's not the best way to do this, and i've not tested in every possible way, but for basic operations, this works form me. I'll will update as i find new issues.