Okay
  Public Ticket #1856628
mySQL table editing
Closed

Comments

  • dalbre started the conversation

    Hello, I have created a mySQL database (flightva_reporting) which is stored on the same domain server than the website I want to use a table  created with wpdatatables.

    I can use SQL as datasource and query tables within that database. In order to do that, I refer to the table by specifying database.table. I use for example:

    SELECT * FROM flightva_reporting.cash_balance

    That works to display the table. However, when try to edit the records in this table or add new records, the plugin seems to try to be saving the data to the wrong database. It tells me someting like:


    "Cant save to flightva_bea.flightva_reporting.cash_balance.fieldname'

    with flightva_bea ... being the wp-standard database on my domain.

    So is there a way to edit data in another mySQL database stored on the same server?


    Many thanks,


    Dirk

  •  2,572
    Aleksandar replied

    Hello Dirk.

    Thank You for Your purchase.

    If You want to edit data in another MySQL database, You need to add the MySQL connection in main settings of wpDataTables:

    6929023899.png

    Then, when You go to create a table, You can actually change the database from the drop-down menu:

    5463883573.png

    Please let me know if this helps.

    Best regards.

    Kind Regards, 

    Aleksandar Vuković
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

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

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables

  • dalbre replied

    Aleksandar, 

    Thanks for the reply. I did explore the "separate DB connection" tab, but I read it was discouraged for performance reasons ... if at all possible.

    I successfully used it to link to a database on separate domain server, so that's working with your method.

    However, can you confirm that this is also the necessary way to go for a a database, stored on the the same domain and registered to the website? I was just wondering, as in that case, the only useful mySQL link supported wihtou a separate connection would be to the WP-databases containing users and posts ... ;-(

    Many thanks,

    Dirk


    PS: Separate question on CRUD ... in a separate ticket.

  •  2,572
    Aleksandar replied

    Hello Dirk.

    I am sorry, but I did not quite understand your previous reply.

    I successfully used it to link to a database on separate domain server, so that's working with your method.

    However, can you confirm that this is also the necessary way to go for a a database, stored on the the same domain and registered to the website?

    From this - I got that you can use a separate database, and that it is working, but after that you ask if it is a necessity to use it if the database is located on the same domain. If you have the database in the same domain, you don't need a separate database, and you can simply use PHPMyAdmin to import a database to where WordPress installation is, and you don't need to use a separate DB connection.

    Or am I missing your question here?

    Best regards.

    Kind Regards, 

    Aleksandar Vuković
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

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

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables

  • dalbre replied

    Alexander, on this one ... maybe I'm making it too compicated. But in my view the custom MySQL tables that contain the data I want to display, sort, edit, delete with wpdatatables could be in three different locations:

    1. in distinct tables, but within the same database as the standard and plug-in maintained Wordpress database tables (those typically prefixed by wp_ ...)
    2. in a separate database, which is, however stored on the same domain server as the WP post,page,... (etc) tables and accessible with similar user privileges as the wp_ tables 
    3. on another ("remote") server (e.g. for data shared with other applications/domains). 


    I understand that wpdatatables MySQL queries work perfectly for #1, without much fuzz and assisted by a specific wizard for query building (thanks for that!!) 

    I also understand that for databases on other servers (#3) I would need to use a separate connection as you suggested in your initial reply. (and I did that before .... let's say there is a country database or client database or some other shared data). On a side note: I haven't managed to combine tables in both locations in a foreign key relationship across databases. Is that actually possible?

    Storing my application custom data in a separate database, but on the same server (i.e. #2), is actually my preferred solution. And that's what my initial question was about: is it possible to do so without a separate DB connection, just by referencing the tables in the form of: database.table 

    SELECT * FROM mydatabase.table 1 WHERE 1 


    Many thanks,


    Dirk



    Thanks,

  •  2,572
    Aleksandar replied

    Hello again dalbre.

    Sorry for late response. 

    Our company is located in Serbia and our working time is from 10:00 to 17:00 CET, business days. We also have a lot of tickets on our hands, so thank you for your patience.

    I understand. Unfortunately, #2 is impossible to do. If you have two databases on the same domain, you can't use a foreign key by using a different connection. For example, if you create a manual table which is stored in WP database, and you want to connect a column using a foreign key to another database on the same domain (with Separate DB being (for example) MYSQL DB) that table will not be visible in the Foreign Key modal, although it will be visible on the tables' list (under wpDataTables).

    I also tried to perform the query like you mentioned

    SELECT * FROM mydatabase.table 1 WHERE 1 

    but the plugin doesn't recognize it in that way.

    What you can try to do is to Create a view that accesses multiple databases in PHPMyAdmin and then use that view in wpDataTables. Something like this was discussed on stack overflow, so you're free to take a look there.

    Please let me know if this helps.

    Best regards, and sorry for any inconvenience.

    Kind Regards, 

    Aleksandar Vuković
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

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

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables