MySQL_Db_Query vs. MySQL_Query - MySQL replication pitfall
I'm updating two MySQL db's - "web" and "stats", these two databases are being replicated. I was wondering that the replication worked when sending queries from a console but with queries from a script it did't ...
the wrong way:
MySQL_Query("UPDATE web.users SET ..... WHERE id = 11444", $writeConnection);
the proper way:
MySQL_Db_Query("web", "UPDATE users SET ..... WHERE id = 11444", $writeConnection);
The catch is that only queries written from within a replicated db are being sent to be replicated - when you send a query without "USE <REPLICATED_DB>" (or the MySQL_Db_Query("<REPLICATED_DB>", ...);) the query won't be replicated - even if it "points" to a replicated db (e.g. "UPDATE <REPLICATED_DB>.table ...".
At least this is how it seems to work for me. :o)
Maybe this would help to someone.