Add joint primary key to wordpress posts table - mysql

I am working out how to synchronize wordpress installations where both can be updated simultaneously, and both can work offline, then come online to sync.
I think the easiest way to sync posts between sites, is to include the site id in the primary key of the posts. Therefore, any post is identified by an incremental id and the id of the server location it was created from.
Is this possible to achieve with a plugin?
What dangers lie ahead if I pursue this path?
Is there a better, alternative way to achieve what I am trying to achieve?

It is possible in several ways:
- Write a stored procedure inside the first Wordpress installation's php files, that inserts the content into the other database when something is written to it. This one probably won't work offline.
- Write a function that compares the two databases at a schedule time using a simple sql query and creates a diff log. Then copies over the difference to the other database.
It depends why you need to do this, but if this works, I would recommend this solution:
- Keep one wordpress installation. Maintain one database, and connect to it from the other website to load the content. You can create your own SQL connection to it and load whatever content you need.
- Keep one wordpress installation, and use it's RSS feed to read the content and display it in whichever second website you need to do it in.
I can't imagine how a plugin would be of much help, especially keeping the databases in sync offline too. In my experience, its usually better to write your custom php scripts, rather than use a plugin so you can have a more direct control over the functionality.
Hope this helps.

Related

PHP script for front-end management of MySql tables

I'm looking for a PHP script that will allow me to easily manage 'MySql' tables. By managing I mean not their creation but the possibility of adding new records, modifying and deleting them.
It must be possible to specify for each user which tables he will have access to and with which modalities (insertion only, modification only, etc.).
For each user I will also have to specify whether he will be able to see all or some of the columns in the table and with which permissions.
Also I'll need to know who did what, a sort of global change LOG.
My idea was to have a back-end in which I specified the users and how to access the various tables/columns and a front-end for the users.
In the front-end users will be able to add/modify/delete records and data they are allowed and the ability to filter and/or sort the various records.
I know I could use some PHP frameworks or rely on CMS but I have to write a lot of code by hand and it seems hardly credible that such a product is not already available.
Does anyone know if there is something like this?
I had tried starting with PHP frameworks but implementing everything from scratch stopped me.
I expect there is already something available.
Thanks.
Davide.

Good method for archiving MYSQL table data?

I recently inherited a website and they have a simple back-end area which was created using phpmaker. The back-end displays various MYSQL database tables.
There are two tables which hold registration information related to promotions/contests the company runs online. The client wants to begin archiving the registration data monthly, but still have the data accessible for future export or review.
So, can anyone tell me what the best approach would be to achieve this? I read about partitioning and Maatkit, but I'm not sure which - if either - would be a smart choice.
I would prefer to keep the table names the same because the table name is referenced in several instances within the PHP code running the promo/contest applications. I would also like for everything to be 'automatic' or at least executed at the click of a button; though I realize that might not be completely realistic.
I should note that I do not have the phpmaker project file and have been unable to obtain it.
Any help on this matter would be a great help.
MK-Archiver This is a good way to archive live mysql database tables
What MK- Archiver does is to archive rows from a table to another table and/or a file

Massive Wordpress database migration

This is a doozy of a question...
I am developing a new wordpress website to replace my client's massively sized blog (tens of thousands of pages). Their existing blog is built on a custom PERL blogging platform from 1992...so as you can imagine, it needs updating.
My job is to find the BEST possible way to migrate all of their existing data into a format that wordpress can understand.
The new theme is very advanced, and this job is very advanced as well. After searching for specialists, I can't seem to find anyone who specialized in this field. What would you do in this situation? Thanks!
I've done this before, it's not that hard. I approached it as a wordpress plugin. First get the plugin to connect to the old database and get it to pull the information you need. Then you can use native wordpress function to insert new users, posts, comments, etc.
I did it line by line, which isn't the most efficient approach, but it is the easiest. I used an AJAX front-end to display the conversion status and repeatedly call the converter back-end, as the actual migration took up to several hours.
If the site can't be shut down for that long while you migrate the database, you could either look at doing a proper bulk export/import, or lock old topics and migrate those over first.
My converter was for an old PHP nuke site, and due to the fact that we were using WP-United, I didn't have to worry too much about user credentials and comments. However, the code might help you get started: http://www.wp-united.com/releases/php-nuke-converter
I have done a couple of these Wordpress migrations. The theme you're using in Wordpress is really not that big a deal, most likely. Themes in Wordpress don't ordinarily impact the database structure.
The Wordpress side is easy, it's in MySQL in most cases. The place to start for you would be to determine how the data in the PERL blog is stored. If it's a custom blog solution, there probably isn't a script you can find to do the migration. Hopefully, it's in a data form that will allow you to do a data dump in a format MySQL will allow you to import using something like phpMyAdmin (a popular GUI for MySQL). At that point, you can create a MySQL statement to match up the relevant fields in your old data with those in MySQL. If you're not comfortable doing it and want an expert, the thing to do is find out how the PERL blog stores it's data and find someone who is familiar with both that format and MySQL.

Configuring Sphinx to index a dynamic set of tables

I'm in the process of setting up a new WordPress 3.0 multisite instance and would like to use Sphinx on the database server to power search for the primary website. Ideally, this primary site would offer the ability to search against its content (posts, pages, comments, member profiles, activity updates, etc.) as well as all of the other sites that are a part of the network. Because we'll be adding new sites to the network on a regular basis, I'd like to be able to dynamically add those newly generated tables to the Sphinx .conf file (instead of editing the file and reindexing every time we add a new site).
Unfortunately, MySQL doesn't seem to support wildcards when specifying the table(s) in a query string. The best solution I've come across for grabbing a dynamic set of tables is grepping but I'm pretty certain I don't know how to do this within the .conf file (unless it's possible through magical sorcery).
Is it possible to dynamically specify tables to add to the Sphinx index? Or is this going to cause such performance issues that I'm using the wrong tool?
You could try to dynamically modify the .conf file instead.
You could query from a MySQL view that aggregates the many tables. You'd have to recreate the view with each change to the list of blogs, but I believe that all the hooks exist to support that and it should be easy enough to construct the view query.
The bigger problem may be in trying to find a suitable unique record ID for the posts in Sphinx. It has to be a straight INT, but the post IDs from the different blogs will collide with each other.
I think you can create triggers (INSERT/UPDATE/DELETE) in MySQL on the interested tables (e.g. posts, comments etc) and migrate the data to centralized global tables that are indexed by Sphinx in real time.
The point is how you can create those triggers automatically? Either you can run a cron job to scan for new tables in MySQL, or I believe you can write a simple Wordpress plugin that hook when a blog is activated.

How can I get my content from a Joomla blog into Blogger or Wordpress?

I have an old joomla site (v 1.0.11) that I would really like to move over to Blogger or Wordpress. The commenting on the site uses AkoComment which was an add on module. Basically, I want to transfer:
posts
comments
users
css
I haven't found a good tool out there to do this. What tools would be best to begin to work with this data? The joomla database is MySql. I would prefer to use blogger as you don't have to pay to host sites on it. That means though that I don't have direct access to the database. Blogger takes Atom feeds as import. The default Atom feed on Joomla will only list the last five posts though, not all, and won't include comments.
Any help here would be appreciated!
There's no easy way. All your user data in particular will be impossible to migrate due to the completely different ways the two systems would handle passwords and so on.
For the posts though, you probably can migrate them. You'll have to study the format of each platform's database tables and create a query or two to migrate data. For example, something like the below would work. Most of the variables listed here are not the actual ones, you'll need to replace them with whatever's appropriate. The 1 is whatever your ID is in the new system.
INSERT INTO wordpress_db.wp_posts ( `wp_author`, `wp_post`, `wp_date` )
SELECT 1, `content`, `posted` FROM joomla_db.jos_content
Write an HTTP bot to submit the data from your database or build a megafeed with all your Joombla blog entries. I personally enjoy coding this kind of scripts.