Loading PODS Data from different Installtion
I am rewriting my PODS based application, and curious if there was the capability to use PODS data stored on a central site, and other sites (multisite, same server, same db server, perhaps even the same db) could pull the data for pick related purposes.
My idea is because of this - 4 of my Pods contain similar information for all of the installs (continents, countries, regions, cities). The resulting size of these 4 pods is close to 5GB and loading them all on each multisite instance would be a terrible waste of space in my opinion.
So with that, would I be able to use in the Add/Public Form Entry screen and display List/Detail items be able to link up to different Pods in a different installation?
My other thought would be to create a field in the single installation of Pods with a siteid or user id field that could be used as a reference point for each site that is adding entries, hereby placing all data on this one main installation. Would I then with an activated copy of Pods on each of the multisites be able to Post/Retrieve data from the central installation?
I suppose I have given two examples for usage.
6 Answers
If it's on WP Multisite, you can use switch_to_blog($blog_id) of the related blog before your Pods code to pull data from that site, then switch back using restore_current_blog() to get back to the original Pods data.
You can mess with $wpdb's connection at any point too, it's been a few years since I did any advanced stuff with it, but it's definitely possible.
If you're adding/saving data using a form, roll your own form or run some hook in the PodsAPI saving process to avoid saving to the current site instead of the db you really want.
I've used the switch_to_blog function with good success and have yet to try this out but was going to be my next step.
Specifically I am interested in storing pick field data (country.city.region) info. Would it be possible to reference the pick fields this way?
I would also like in a PODS installation to reference pick information from another blog_id in the setup manager. I'm assuming there would be considerable hacking to do this, unless you know otherwise.
Definitely a lot of hacking, I'd suggest just creating a text field and storing the ID for the related item on the other server/db there. Then for the input field, use an input helper and build your list dynamically from the data on the other server/db.
Sure, I understand - Will take me a bit to figure out the PHP as I'm still cutting my teeth but possible with a bit of overhead per installation - There are over 5000 records and growing, but that's fine.
Thanks for this! Looking forward to 2.0 to see if it solves some of my shortcomings.
I was just thinking this over for the past few days and wondering if there was at all the possibility or a feature request that had been submitted yet to have a relationship to a custom SQL View - If I created the view in each Pods Installation to reference the main master DB with all the files. Am I off track with this idea?


