Events Made Easy › Forums › How do I … › Pull from another MySQL DB?
- This topic has 17 replies, 3 voices, and was last updated 11 years ago by Franky.
-
AuthorPosts
-
Tue 10 Dec 2013 at 15:33 #44103AnonymousInactive
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.
Tue 10 Dec 2013 at 15:56 #50943FrankyKeymasterSorry but that’s not possible. Event id’s could be double etc … so you should look for multisite. EME is fully multisite compatible, btw.
Tue 10 Dec 2013 at 16:09 #50944AnonymousInactiveAlternatively 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 🙂
Tue 10 Dec 2013 at 16:47 #50945FrankyKeymasterHi Tom, feel free to post the json example in the Tips section then 🙂
Tue 10 Dec 2013 at 17:01 #50946AnonymousInactiveI will do once I’ve developed it a bit more. Probably a few weeks away just yet though…
Tue 10 Dec 2013 at 20:53 #50947AnonymousInactiveOkay, 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?
Tue 10 Dec 2013 at 21:59 #50948FrankyKeymasterThat is multisite: one wo install, one db but new tables per site so they are independant for content. It is just easier to maintain
Tue 10 Dec 2013 at 22:04 #50949AnonymousInactiveIs there a way to make each site access the same table in the DB? That’s the functionality I was looking for.
Tue 10 Dec 2013 at 22:41 #50950FrankyKeymasterNope, wordpress doesn’t support that out of the box. Some other plugins might help you here, maybe google for “wordpress multisite copy db content”
Thu 12 Dec 2013 at 04:05 #50951AnonymousInactiveI 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.
Thu 12 Dec 2013 at 04:57 #50952AnonymousInactiveIn 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.
Thu 12 Dec 2013 at 08:56 #50953FrankyKeymasterI 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 …
Sat 21 Dec 2013 at 18:12 #50954AnonymousInactiveOk, 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!
Sat 21 Dec 2013 at 22:49 #50955FrankyKeymasterI 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 …
Sun 22 Dec 2013 at 19:55 #50956AnonymousInactiveFranky, 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.
Sun 22 Dec 2013 at 21:05 #50957FrankyKeymasterNo, it does not. It is executed just before the event is entered in the db, nothing more.
Sun 22 Dec 2013 at 21:09 #50958AnonymousInactiveAh, bummer. I’m at a bit of a brick wall on this for now.
Sun 22 Dec 2013 at 23:58 #50959FrankyKeymasterI’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 …
-
AuthorPosts
- The forum ‘How do I …’ is closed to new topics and replies.