On Mon, 29 Jun 2009 15:38:01 +0200 Michel Morelli michel@ziobuddalabs.it wrote:
Ivan Sergio Borgonovo ha scritto:
Could it be that cck saves the names of the tables for a content type inside a field in a table?
You'll have to do something like
update [someccktable|somecontentypetable] set field=replace(...field
No no no no ... the solution (or the problem) is that cck module create table's schema from table stored in the database and DRUPAL use this function to check if a table exists:
SHOW TABLES LIKE 'XXXX'
but this function works only for tables that are defined into the database in use. In my case I have a shared database, so if you want to share cck-content type via a shared db you can't. You can share node, but not cck-node. grrrrrr... 4 hours lost...
mmm well there are several problems about db_table_exists.
1) db_escape_table don't accept '.' in table names (at least in D5) 2) SHOW TABLES should be changed with something more DB agnostic using information_schema that should be supported by MySQL 5.X as well (I think this has been fixed)
I'm really not aware how MySQL mix and match schema and db connections. So it may not be too easy to patch core for your needs. If I were in pg land a quick hack could be
function db_table_exists($table) { $tn=split('.', $table); if(count($tn)==1) { $tn[1]=$tn[0]; $tn[0]='public'; /* could be worth to skip it and rely on search path */ }; return db_num_rows(db_query(" select table_name from information_schema.tables where table_name='".db_escape_table($tn[1]). "' and table_schema='".db_escape_table($tn[0])."')); } // not tested
Anyway it is worth a try to see if replacing db_table_exists with something more similar to the pg version may work.
You may hack mysql version so that it switch connection according to the "prefix". A bit of pain...
I think there were some improvement about db_table_exists (and schema support??) in D7.
Good to know that CCK don't work "very well" if not at all in a shared DB environment.
Isn't CCK getting into core as Fields?
grepping in D5 code there is not much use of db_table_exists still there are a bunch of places where db_escape_table don't play nice with schemas. (domain and sequences up to my memory). You may check if you may experience similar problems for mysql and maybe you could get around this.