0

I already asked the question, and tried the solutions which was given to me here in stackoverflow, but it was not was i was searching: Select columns across different databases

So i repost my question: i managed to install xampp with wordpress on localhost. In a subfolder of wordpress i installed a php program. Everything works well, but i have a problem, i want my wordpress members to be able to login and use my php program (a web app). The problem is that's i'm just started to learn php a few weeks ago, so i can't really do it, i don't have money to spend on a developer, so this site is my only help.

I found an easier way for me to do essentially the same, but i have some problems implementing it: i want to link bitnami_wordpress.wp_user (first table with wordpress user information) with cm2.cm_user (php app table with user information). Essentially i want to update the table ucm_user informations based on information on wp_user automatically, without me intervening in phpmysql, i.e. if someone update his password on wordpress for example i want his password also to be updated on database2, if i delete or add an user on wordpress i want them also to be deleted or added on database2 from my web app. All this automatically without me intervening.

The informations on the two database are:

bitnami_wordpress.wp_user: user_id email password

and

cm.cm_user: ID email password name last name

The sql query did not do what i wanted: Add, Update or Delete AUTOMATICALLY a user in cm.cm_user when i add, update or delete a user on wordpress.

Should i use triggers? If yes, how?

So can anyone help me please?

Thanks to everyone!

Community
  • 1
  • 1
  • You mind supplying this query that `"did not do what i wanted"`? – Darren Jul 17 '14 at 00:07
  • "All this automatically without me intervening." So you believe in magic then? At some point in time, you need to intervene and do programming to make this work. – skrilled Jul 17 '14 at 00:07
  • If you do not know much PHP wouldn't it be easier to replicate the mysql information? http://stackoverflow.com/questions/2111319/synchronize-2-databases-installed-locally-with-xampp or you can manually do replication with this tutorial http://dev.mysql.com/doc/refman/5.7/en/replication-howto.html – Robert Lee Jul 17 '14 at 00:48
  • I'm sorry if i was not clear, essentially i want the database part to be automatic. Let's say a user on wordpress updates his data, the data at this moment would be updated only on the first database's table not the second. What i want is essentially when the user or i update a data on wordpress (manually of course), the data should be updated automatically on db1 table1 and db2 table2 (only this part automatically without me intervening) – user3810595 Jul 17 '14 at 00:54
  • how do you automatically add a user when name and last_name are unknown? – Fabricator Jul 17 '14 at 01:33

1 Answers1

0

You will need to create a TRIGGER on bitnami_wordpress.wp_user for INSERT/UPDATE/DELETE. The catch is that you cannot make a cross database update from within a trigger, but you can call a STORED PROCEDURE from a TRIGGER that does update a table in a different database.

Community
  • 1
  • 1
doublesharp
  • 26,888
  • 6
  • 52
  • 73