I tried to import almost a hundred CVS entries to my drupal 6.14 installation with my self-defined content type nodes. It fails to import due to SQL error somewhere in importexportapi_db_put.inc saying {base_db}.{table_prefix_}{table_prefix_}{target_table} does not exists.

I believe it is from every "SELECT ... FROM { $into } ..." queries where $into has `already prefixed` and tried to be prefixed again when concatenating to the actual SQL, leading to a queries to the table that does not exists in the database.

I have made some changes on engines/importexportapi_db_put.inc (see attached diff file) and it solved my problem. Although not really sure on the changes I made, but I think it has something to do with it at least.

CommentFileSizeAuthor
engines.diff3.17 KBbub
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Anonymous’s picture

Priority: Normal » Critical
Issue tags: -sql, -table prefix

Thanks for the patch. I'll take a look later this month (January 2010).

timmyxiao’s picture

> When I import testdata/user_data.xml via importexportapi, appear some
> warning.
>
> ------------------------------
> user warning: Table 'devel.dv_dv_users' doesn't exist query: SELECT
> COUNT(uid) FROM dv_dv_users WHERE uid = 2 in
> /var/www/drupal6/sites/all/modules/tools/importexportapi/engines/importexportapi_db_put.inc
> on line 533.
> user warning: Table 'devel.dv_dv_role' doesn't exist query: SELECT name FROM
> dv_dv_role WHERE rid = 3 in
> /var/www/drupal6/sites/all/modules/tools/importexportapi/engines/importexportapi_db_put.inc
> on line 627.
> user warning: Table 'devel.dv_dv_profile_fields' doesn't exist query: SELECT
> title FROM dv_dv_profile_fields WHERE fid = 1 in
> /var/www/drupal6/sites/all/modules/tools/importexportapi/engines/importexportapi_db_put.inc
> on line 627.
> user warning: Table 'devel.dv_dv_profile_fields' doesn't exist query: SELECT
> name FROM dv_dv_profile_fields WHERE fid = 1 in
> /var/www/drupal6/sites/all/modules/tools/importexportapi/engines/importexportapi_db_put.inc
> on line 627.
> user warning: Table 'devel.dv_dv_profile_fields' doesn't exist query: SELECT
> title FROM dv_dv_profile_fields WHERE fid = 2 in
> /var/www/drupal6/sites/all/modules/tools/importexportapi/engines/importexportapi_db_put.inc
> on line 627.
> user warning: Table 'devel.dv_dv_profile_fields' doesn't exist query: SELECT
> name FROM dv_dv_profile_fields WHERE fid = 2 in
> /var/www/drupal6/sites/all/modules/tools/importexportapi/engines/importexportapi_db_put.inc
> on line 627.
> user warning: Table 'devel.dv_dv_profile_fields' doesn't exist query: SELECT
> title FROM dv_dv_profile_fields WHERE fid = 3 in
> /var/www/drupal6/sites/all/modules/tools/importexportapi/engines/importexportapi_db_put.inc
> on line 627.
> user warning: Table 'devel.dv_dv_profile_fields' doesn't exist query: SELECT
> name FROM dv_dv_profile_fields WHERE fid = 3 in
> /var/www/drupal6/sites/all/modules/tools/importexportapi/engines/importexportapi_db_put.inc
> on line 627.
> user warning: Table 'devel.dv_dv_profile_fields' doesn't exist query: SELECT
> title FROM dv_dv_profile_fields WHERE fid = 4 in
> /var/www/drupal6/sites/all/modules/tools/importexportapi/engines/importexportapi_db_put.inc
> on line 627.
> user warning: Table 'devel.dv_dv_profile_fields' doesn't exist query: SELECT
> name FROM dv_dv_profile_fields WHERE fid = 4 in
> /var/www/drupal6/sites/all/modules/tools/importexportapi/engines/importexportapi_db_put.inc
> on line 627.
> user warning: Table 'devel.dv_dv_users' doesn't exist query: SELECT
> COUNT(uid) FROM dv_dv_users WHERE uid = 3 in
> /var/www/drupal6/sites/all/modules/tools/importexportapi/engines/importexportapi_db_put.inc
> on line 533.
> user warning: Table 'devel.dv_dv_role' doesn't exist query: SELECT name FROM
> dv_dv_role WHERE rid = 3 in
> /var/www/drupal6/sites/all/modules/tools/importexportapi/engines/importexportapi_db_put.inc
> on line 627.
> user warning: Table 'devel.dv_dv_role' doesn't exist query: SELECT name FROM
> dv_dv_role WHERE rid = 4 in
> /var/www/drupal6/sites/all/modules/tools/importexportapi/engines/importexportapi_db_put.inc
> on line 627.
> user warning: Table 'devel.dv_dv_profile_fields' doesn't exist query: SELECT
> title FROM dv_dv_profile_fields WHERE fid = 3 in
> /var/www/drupal6/sites/all/modules/tools/importexportapi/engines/importexportapi_db_put.inc
> on line 627.
> user warning: Table 'devel.dv_dv_profile_fields' doesn't exist query: SELECT
> name FROM dv_dv_profile_fields WHERE fid = 3 in
> /var/www/drupal6/sites/all/modules/tools/importexportapi/engines/importexportapi_db_put.inc
> on line 627.
> user warning: Table 'devel.dv_dv_profile_fields' doesn't exist query: SELECT
> title FROM dv_dv_profile_fields WHERE fid = 2 in
> /var/www/drupal6/sites/all/modules/tools/importexportapi/engines/importexportapi_db_put.inc
> on line 627.
> user warning: Table 'devel.dv_dv_profile_fields' doesn't exist query: SELECT
> name FROM dv_dv_profile_fields WHERE fid = 2 in
> /var/www/drupal6/sites/all/modules/tools/importexportapi/engines/importexportapi_db_put.inc
> on line 627.
> user warning: Table 'devel.dv_dv_profile_fields' doesn't exist query: SELECT
> title FROM dv_dv_profile_fields WHERE fid = 1 in
> /var/www/drupal6/sites/all/modules/tools/importexportapi/engines/importexportapi_db_put.inc
> on line 627.
> user warning: Table 'devel.dv_dv_profile_fields' doesn't exist query: SELECT
> name FROM dv_dv_profile_fields WHERE fid = 1 in
> /var/www/drupal6/sites/all/modules/tools/importexportapi/engines/importexportapi_db_put.inc
> on line 627.
> user warning: Table 'devel.dv_dv_profile_fields' doesn't exist query: SELECT
> title FROM dv_dv_profile_fields WHERE fid = 4 in
> /var/www/drupal6/sites/all/modules/tools/importexportapi/engines/importexportapi_db_put.inc
> on line 627.
> user warning: Table 'devel.dv_dv_profile_fields' doesn't exist query: SELECT
> name FROM dv_dv_profile_fields WHERE fid = 4 in
> /var/www/drupal6/sites/all/modules/tools/importexportapi/engines/importexportapi_db_put.inc
> on line 627.
> warning: mysqli_real_escape_string() expects parameter 2 to be string, array
> given in /var/www/drupal6/includes/database.mysqli.inc on line 323.
> warning: mysqli_real_escape_string() expects parameter 2 to be string, array
> given in /var/www/drupal6/includes/database.mysqli.inc on line 323.
> warning: mysqli_real_escape_string() expects parameter 2 to be string, array
> given in /var/www/drupal6/includes/database.mysqli.inc on line 323.
> warning: mysqli_real_escape_string() expects parameter 2 to be string, array
> given in /var/www/drupal6/includes/database.mysqli.inc on line 323.
> user warning: Table 'devel.dv_dv_importexportapi_db_put_map_alt' doesn't
> exist query: SELECT * FROM dv_dv_importexportapi_db_put_map_alt WHERE put_id
> = 1 AND entity = 'user' AND field = 'uid' AND alt_field = 'name' AND
> value_alt = 'Bobby' in
> /var/www/drupal6/sites/all/modules/tools/importexportapi/engines/importexportapi_db_put.inc
> on line 848.
> user warning: Duplicate entry '0' for key 1 query: INSERT INTO
> dv_importexportapi_db_put_map_alt (put_id, entity, field, alt_field,
> value_alt, value_key) VALUES (1, 'user', 'uid', 'name', 'Bobby', '2') in
> /var/www/drupal6/sites/all/modules/tools/importexportapi/engines/importexportapi_db_put.inc
> on line 859.
> user warning: Table 'devel.dv_dv_importexportapi_db_put_map_alt' doesn't
> exist query: SELECT * FROM dv_dv_importexportapi_db_put_map_alt WHERE put_id
> = 1 AND entity = 'user' AND field = 'uid' AND alt_field = 'name' AND
> value_alt = 'Kate' in
> /var/www/drupal6/sites/all/modules/tools/importexportapi/engines/importexportapi_db_put.inc
> on line 848.
> user warning: Duplicate entry '0' for key 1 query: INSERT INTO
> dv_importexportapi_db_put_map_alt (put_id, entity, field, alt_field,
> value_alt, value_key) VALUES (1, 'user', 'uid', 'name', 'Kate', '3') in
> /var/www/drupal6/sites/all/modules/tools/importexportapi/engines/importexportapi_db_put.inc
> on line 859.
> user warning: Table 'devel.dv_dv_importexportapi_db_put_map_alt' doesn't
> exist query: SELECT * FROM dv_dv_importexportapi_db_put_map_alt WHERE put_id
> = 1 AND entity = 'user' AND field = 'uid' AND alt_field = 'mail' AND
> value_alt = 'bob@byy.com' in
> /var/www/drupal6/sites/all/modules/tools/importexportapi/engines/importexportapi_db_put.inc
> on line 848.
> user warning: Duplicate entry '0' for key 1 query: INSERT INTO
> dv_importexportapi_db_put_map_alt (put_id, entity, field, alt_field,
> value_alt, value_key) VALUES (1, 'user', 'uid', 'mail', 'bob@byy.com', '2')
> in
> /var/www/drupal6/sites/all/modules/tools/importexportapi/engines/importexportapi_db_put.inc
> on line 859.
> user warning: Table 'devel.dv_dv_importexportapi_db_put_map_alt' doesn't
> exist query: SELECT * FROM dv_dv_importexportapi_db_put_map_alt WHERE put_id
> = 1 AND entity = 'user' AND field = 'uid' AND alt_field = 'mail' AND
> value_alt = 'kate@waa.com' in
> /var/www/drupal6/sites/all/modules/tools/importexportapi/engines/importexportapi_db_put.inc
> on line 848.
> user warning: Duplicate entry '0' for key 1 query: INSERT INTO
> dv_importexportapi_db_put_map_alt (put_id, entity, field, alt_field,
> value_alt, value_key) VALUES (1, 'user', 'uid', 'mail', 'kate@waa.com', '3')
> in
> /var/www/drupal6/sites/all/modules/tools/importexportapi/engines/importexportapi_db_put.inc
> on line 859.
> ---------------------------
>
> I find the SQL string is following, it is in file
> importexportapi/engines/importexportapi_db_put.inc.
>
> SELECT COUNT(uid) FROM {users}
>
> when calling function, {users} change into dv_ users, and {{users}} change
> into dv_dv_ users, dv is the prefix of my table in database.
>
> when I modify this line at no 526 in file
> importexportapi/engines/importexportapi_db_put.inc.
>
> before modifying -> $into = '{'. $key_put['#db_table'] .'}';
>
> After modifying -> $into = $key_put['#db_table'] ;
>
> That Sql string change into the following.
>
> SELECT COUNT(uid) FROM {users}
>
> And that warning was removed.
>
> The other waring was removed too using same modth.
>

bub’s picture

Title: Table prefix duplication for import from CVS » Table prefix duplication for import from CSV

wrong title.