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!

5
  • You mind supplying this query that "did not do what i wanted"? Commented Jul 17, 2014 at 0: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. Commented Jul 17, 2014 at 0:07
  • If you do not know much PHP wouldn't it be easier to replicate the mysql information? stackoverflow.com/questions/2111319/… or you can manually do replication with this tutorial dev.mysql.com/doc/refman/5.7/en/replication-howto.html Commented Jul 17, 2014 at 0: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) Commented Jul 17, 2014 at 0:54
  • how do you automatically add a user when name and last_name are unknown? Commented Jul 17, 2014 at 1:33

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you doublesharp, that's what i was searching!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.