Events Made Easy Forums How do I … Pull from another MySQL DB?

Tagged: ,

Viewing 18 posts - 1 through 18 (of 18 total)
  • Author
    Posts
  • #44103
    Anonymous
    Inactive

    I don’t even know if this is possible, but can I set up EME to access another website’s MySQL EME table? This sure would be awesome as I have a “mother” site and several “child” websites that have duplicate events. I am not using wordpress multisite, but am definitely contemplating it if this doesn’t work.

    #50943
    Franky
    Keymaster

    Sorry but that’s not possible. Event id’s could be double etc … so you should look for multisite. EME is fully multisite compatible, btw.

    #50944
    Anonymous
    Inactive

    Alternatively you could make the events available in JSON format via an API.

    I’m working on something similar at the moment and would be happy to share if you’re interested.

    Here’s an example:

    http://plainandsimple.tv/api/eme-json.php

    And Franky – this time it’s using eme_get_events() instead of a direct MySQL Query 🙂

    #50945
    Franky
    Keymaster

    Hi Tom, feel free to post the json example in the Tips section then 🙂

    #50946
    Anonymous
    Inactive

    I will do once I’ve developed it a bit more. Probably a few weeks away just yet though…

    #50947
    Anonymous
    Inactive

    Okay, so I installed wordpress multisite so that I could use my child sites as “satellites”, accessing the eme DB, but when I activated the plugin on the new site, it was a fresh db! What did I do wrong and how do I fix it?

    #50948
    Franky
    Keymaster

    That is multisite: one wo install, one db but new tables per site so they are independant for content. It is just easier to maintain

    #50949
    Anonymous
    Inactive

    Is there a way to make each site access the same table in the DB? That’s the functionality I was looking for.

    #50950
    Franky
    Keymaster

    Nope, wordpress doesn’t support that out of the box. Some other plugins might help you here, maybe google for “wordpress multisite copy db content”

    #50951
    Anonymous
    Inactive

    I don’t just want to make a copy of the information, I want it live, accessible to all websites within the network that have the plugin enabled.

    Could you point me to which file(s) in your plugin that determines which db table to create/use?

    I have a programmer friend that may be willing to help me extend the plugin to have this functionality.

    #50952
    Anonymous
    Inactive

    In doing some digging into the plugin, here is what I found:

    Currently, the EME plugin installed on each site reflect different data. That is because, it seems, that the multisite actually prefixes the db tables with a unique id: “wp_” for the original site (minutemenministries.org), “wp_3_” for the second site (jimvangelderen.org). See phpMyAdmin screenshot here.

    What I would like to do is to somehow “trick” the satellite sites to always use the “wp_” tables for the EME plugin. As far as I can understand this would solve everything. As long as each satellite site is “tricked” all the data entered is available and editable to every site.

    Now as far as extending the plugin itself, I am not sure how that is going to work. From what rooting around I could do I found that in events_manager.php, on lines 115-123 it defines variables for “eme_answers”, “eme bookings”, “eme_categories”, etc from the tables above. I searched for these variables and found that just about each time they are used, the code “$wpdb->prefix.” is affixed before it. From what I can tell from this codex document, “$wpdb” is a WordPress global variable for talking to the database and “prefix” is a class variable that adds the aforementioned prefixes to the tables. In the same codex document, right below the definition for “$prefix”, it talks about about another class variable, “$base_prefix”, saying:

    “The original prefix as defined in wp-config.php. For multi-site: Use if you want to get the prefix without the blog number appended.”

    That might just be what we’re looking for!

    I sent this information to my programmer friend to see if he can figure something out with it, but I thought I’d check in here too just to see if it could ever even be done.

    #50953
    Franky
    Keymaster

    I never heard of that variable before but it might just work.

    I think I’ll move the use of “prefix” into just the main file, so it will be easier to change these things later on, but that’s just cosmetic …

    #50954
    Anonymous
    Inactive

    Ok, my friend looked through the code and he thinks that the solution is just as I said. My question is this, what would be the best way to test something like this? Is it possible to extend the plugin so that it continues to update with new updates? Can I install a separate instance of the plugin that I use on my “Child” sites, so that it doesn’t mess up what I currently have working? Would two versions of a plugin on the same multisite network mess anything up? Agh! I don’t want to blow up my site with this thing!

    #50955
    Franky
    Keymaster

    I don’t think you can install different versions per multisite subsite. So it would need to be an option in the main plugin code to survive any upgrade …

    #50956
    Anonymous
    Inactive

    Franky, thanks for the great update. Lots of good stuff.

    Does the “eme_event_preinsert_filter” feature have anything to do with the topic of this thread (integrating multisite database tables)? Forgive my ignorance. I have done nothing with hooks or filters other than look them up in the WordPress glossary a few minutes ago.

    #50957
    Franky
    Keymaster

    No, it does not. It is executed just before the event is entered in the db, nothing more.

    #50958
    Anonymous
    Inactive

    Ah, bummer. I’m at a bit of a brick wall on this for now.

    #50959
    Franky
    Keymaster

    I’m sorry, but changing that part of the code would render other peoples proper extensions inactive.

    So for now you’ll have to change that part of the code yourself.

    Of course the existing filters can help here, but it’s not going to be a perfect solution …

Viewing 18 posts - 1 through 18 (of 18 total)
  • The forum ‘How do I …’ is closed to new topics and replies.
Scroll to Top