Okay
  Public Ticket #1290848
Update of tables
Closed

Comments

  •  1
    protonelectron started the conversation

    Hi, 

    I have set up a table to be editable, however it is in a different schema to my wordpress installation. When I set the table to be edited, it appends the wordpress schema name as prefix, in front of the full schema.table name. 

    I have checked the user permissions and the default wordpress mysql account has full permissions to the desired schema. 

    Is there any way to stop the plugin appending the default wordpress schema name to the front of the table name? i would be willing to have to enter in the full schema.table name for each table that needs updating (as opposed to just the table name at current). 

    I don't want to change the plugin settings to a custom one as I still need other tables to write to databases within that schema, so if i change it they will become useless. 

    Cheers,

    Dave

    UPDATE: I have managed to fix the problem by adding in a column to the wpdatatables table that holds the schema name for the table i want to write too. I then just replaced if statement at line 336 in the wdt_ajax_actions.php file with:

    $newwpdb = new wpdb(DB_USER, DB_PASSWORD, $mySqlSchemaName, DB_HOST);
     if ($idVal != '0') {
                $res = $newwpdb->update($mySqlTableName,
                    $formData,
                    array(
                        $idKey => $idVal
                    )
                );

                if (!$res) {
                    if (!empty($newwpdb->last_error)) {
                        $returnResult['error'] = __('There was an error trying to update the row! Error: ', 'wpdatatables') . $newwpdb->last_error;
                    } else {
                        $returnResult['success'] = $idVal;
                    }
                } else {
                    $returnResult['success'] = $idVal;
                }
            } else {
                $returnResult['is_new'] = true;
                $res = $newwpdb->insert($mySqlTableName,
                    $formData);
                if (!$res) {
                    $returnResult['error'] = __('There was an error trying to insert a new row! Error: ', 'wpdatatables') . $newwpdb->last_error;
                } else {
                    $returnResult['success'] = $newwpdb->insert_id;
                    $idVal = $newwpdb->insert_id;
                }
            }

    And placed the below on a line below line 196 in the same file. 

     $mySqlSchemaName = $tableData->mysql_table_schema_name;

    You can then just use the normal windows to set it all up. You just put only the table name in the editable table box in the table settings, and then put the schema name in the new column manually. 

  •  472
    Isidora replied

    Hi Dave,
    Thank you for your purchase.

    I am glad that you have resolved your issue.

    Best regards.

    Kind Regards, 

    Isidora Markovic

    wpDataTables: FAQFacebookTwitterFront-end and back-end demoDocs

    Amelia: FAQFacebookTwitter |  Amelia demo sites | Docs

    You can try our wpDataTables add-ons before purchase on these sandbox sites:

    Powerful FiltersGravity Forms Integration for wpDataTablesFormidable Forms Integration for wpDataTables