External Database
-
Hello
Is there some way to share pods tables between different sites?
like I would like to put whole pods tables/stuff into database, separated from wordpressThank you
-
It’s a great idea, I think it would be possible by filtering the table name we use, see below:
add_filter( 'pods_api_get_table_info', 'my_custom_pods_table_location' ); /** * Filter the table location for your Pod. * * @param array $table_info Table info configuration. * * @return array */ function my_custom_pods_table_location( $table_info ) { if ( 'pod' === $table_info['type'] && 'my_act_pod' === $table_info['object_name'] ) { $table_info['table'] = 'some_other_table_name'; $table_info['meta_table'] = $table_info['table']; } return $table_info; }There’s an example where I have an Advanced Content Type pod named “my_act_pod” and I’m filtering the table we use in Pods. This table, when you create the pod and modify it, will get it’s table columns modified. So be sure you have the Pod set up the way you want it in all the places you want first before adding the table name filter.
-
This reply was modified 7 years, 5 months ago by
Scott Kingsley Clark.
Hi
Thank you for reply, but I dont get an idea.
Say, my wordpress database is located on localhost, but my pods database is located somwhere else (somehost:port)
How shell I configure the PODs, to let them walk into another MySQL instance?
I am not so strong in WP…Thank you
-
This reply was modified 7 years, 5 months ago by
max1024.
That won’t work here. What you can do is set the table name to use another database the current MySQL user has access too though. For instance, if your WordPress sites are on their own databases, but the MySQL user has access to a “custom_data” database, you can set the table to be
custom_data.some_other_table_nameand it will access the data on that other database — pretty cool!Sorry about not being able to reference data on another MySQL connection, that’s something we don’t have the ability to do at all within Pods or WP when mixing data and queries.
Now, if you want to add a relationship to that data, but you don’t need to query that data from the Pods context, you can definitely do that with custom relationship objects:
add_action( 'pods_form_ui_field_pick_related_objects_other', 'my_custom_pods_relationships' ); /** * Register your custom relationship object. */ function my_custom_pods_relationships() { PodsField_Pick::$related_objects['my_custom_relationship'] = array( 'label' => 'My custom relationship object', 'group' => __( 'Advanced Objects', 'pods' ), 'simple' => true, 'data_callback' => 'my_custom_pods_relationship_data', ); } /** * Data callback for your custom relationship object. * * @param string $name The name of the field. * @param string|array $value The value of the field. * @param array $options Field options. * @param array $pod Pod data. * @param int $id Item ID. * * @return array */ function my_custom_pods_relationship_data( $name = null, $value = null, $options = null, $pod = null, $id = null ) { $data = array(); // Set up your own Database WPDB connection or call the API you want. // Add data in this format: $data['key'] = 'Label'; return $data; }-
This reply was modified 7 years, 5 months ago by
Scott Kingsley Clark.
-
This reply was modified 7 years, 5 months ago by
Scott Kingsley Clark.
Thanks for reply
What about FEDERATE tables? Will it works with Pods?It’s possible, but it’s never been tested. Let us know how it goes π
If you get it working, bonus points if you can provide a tutorial on how to do that kind of setup, it would be really cool to show our users how to get that to work.
Hi
ok I will try both ways and post the results hereHello
looks like it is not so easy
when I go with first approach Ive got
WordPress database error: [Table 'wordpress_database.my_storage.wps_pods_test' doesn't exist]
Looks like a WP databasename was added before my custom database name as well
brief look through code doesnt ring the bellMaxim
Hello
Ive played with FEDERATE (CONNECT actually)
got some results
But I feel that place could be uncomfortable to discuss it
any suggestions?
Thank you -
This reply was modified 7 years, 5 months ago by
The topic ‘External Database’ is closed to new replies.