• When I attempt to “Add New” child row in a many to many relationship, I get an insert error.
    The child row is created but the links between the two tables are not.
    Add existing does not get an error.
    See the PHP log entry below:

    family ==> member ==> details

    Table family has the parent record
    Table details has the child record
    the row fails to insert into table member

    The database is named directory…. not wp_testsite_db

    [02-Apr-2022 03:55:51 UTC] WordPress database error Table ‘wp_testsite_db.member’ doesn’t exist for query
    SHOW FULL COLUMNS FROM member
    made by do_action(‘directory_page_wpda_wpdp_1_1’), WP_Hook->do_action, WP_Hook->apply_filters, WPDataProjects\WPDP->manage_project_page, WPDataProjects\Parent_Child\WPDP_Parent_List_View->show, WPDataProjects\Parent_Child\WPDP_Parent_List_View-

    How can I fix this?

    The page I need help with: [log in to see the link]

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter Henry Sautter (Hank)

    (@hlsautter)

    ========================================================

    I created a new WordPress host installation
    Added the WP Data plugin

    created three tables and added them to a project

    events ==> attendance ==> details

    setup as a many to many relationship
    added a new event then selected “Add New” to add a member attending the event.

    INFO: Succesfully saved changes to database ==>. new member created

    ERROR: Error create relationship (insert failed) ==> row not added to attendance table

    Table attendance is NOT in the wp_host2_db database
    It is in the directory2 database with the other tables.

    [03-Apr-2022 01:33:05 UTC] WordPress database error Table 'wp_host2_db.attendance' doesn't exist for query 
    SHOW FULL COLUMNS FROM <code>attendance</code> made by do_action('toplevel_page_wpda_wpdp_1_1'), WP_Hook->do_action, WP_Hook->apply_filters, WPDataProjects\WPDP->manage_project_page, WPDataProjects\Parent_Child\WPDP_Parent_List_View->show, WPDataProjects\Parent_Child\WPDP_Parent_List_View->display_edit_form, WPDataProjects\Parent_Child\WPDP_Parent_Form->show, WPDataProjects\Parent_Child\WPDP_Parent_Form->show_child_form, WPDataAccess\Simple_Form\WPDA_Simple_Form->prepare_form, WPDataProjects\Parent_Child\WPDP_Child_Form->prepare_row

    ==================================================

    Table ATTENDANCE
    Select All Id EventID MemberID
    No data found

    ===================================================

    Plugin Author Passionate Programmer Peter

    (@peterschulznl)

    Hi Hank,

    You can only create a relationship between two tables if they are in the same database schema. From your question I understand they are in different databases? Is that correct?

    If so, how did you add a table to a relationship in another database?

    Thanks,
    Peter

    Hi Henry/Peter,
    if “The database is named directory” means DBNAME=”Directory”, isn’t Directory a mySql reserved word?

    Sorry in case of misunderstanding..

    Thread Starter Henry Sautter (Hank)

    (@hlsautter)

    All the tables are in the database Directory and Directory2
    So I am NOT attempting to access data in two different databases.
    The plugin code is making the “assumption” that the table attendance is in the wp_host2_db.

    Table ‘wp_host2_db.attendance’ doesn’t exist

    I have not had any issues accessing the table in other features of the plugin.
    Just the “add New” button associated with a many to many table relationship.

    I was not aware of “Directory” being a reserved word for mysql.
    However, I used the name Directory2 for the simplified install host I used for debug and the result is the same.

    Plugin Author Passionate Programmer Peter

    (@peterschulznl)

    Hi Hank,

    Sorry for my late reply!

    Is this data transfered from another server? If you transfer projects or publication from one server to another using WP Data Access export/import, the database name is automatically updated. This does not happen with external tools. In that case you need to manually update the database name. You can download a script and instructions from this page:
    https://wpdataaccess.com/docs/documentation/data-explorer/transfer-to-other-wordpress-database/

    Does this help?

    Thanks,
    Peter

    Thread Starter Henry Sautter (Hank)

    (@hlsautter)

    Thanks for the pointer to the rename information.
    However that is not the issue here.

    The schema_names in all the wp_wpda tables is set to directory2.
    The database directory2 is separate from the wp database.
    The wp_wpda functions all seem to access the correct database
    except for the insert_row code for the many-to-many tables which attempts to get the column names for the attendance table from the wp database instead of directory2.

    Plugin Author Passionate Programmer Peter

    (@peterschulznl)

    Hi Hank,

    Found it! And fixed it!

    Your last comment helped to reproduce this issue. Thank you for being so patient and determined! 👍 Hope to release an update tomorrow which contains the fix.

    Thanks,
    Peter

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Many to Many relationship – Add New – insert fails’ is closed to new replies.