Insert Row into another database

I would like to be able to insert the user data after a certain product is purchased into another database. The databases reside on the same server, just different logins. Also if the user updates any personal data, I’d like to update that record in the other database as well. Basically I’m trying to keep a wordpress user table in sync with a cscart user table but the data only enters the wp table when a certain product is purchased.



I am assuming I’ll do this as an addon, as to not disturb the core code for an easier upgrade path. Any ideas?

I would use the same DB with different table prefixes, it would be easier. But if you do it that way you’re going to need to create a new database connection in the ‘add-on’. Then you’re going to need to figure out how to get the resorce identifier for the original connection, switch to the new connection, and then back again with mysql_select_db.



I don’t know if the cart uses the resource identifier for the connection or not. If you don’t then by default it was the last one that was established. So if you establish a new one, then it will screw it all up. You would have to reestablish it over again when you’re done with the other db.



Edit: just noticed this was an old post.