How to do transactions between multiple database in a mysql server?

Below is my sequence of code

// global autocommit is 1

db->query('SET AUTOCOMMIT=0');
db->query('BEGIN');
db->query('INSERT INTO TRANSACTIONS (CREDIT) VALUES (150)');
db->chagngeDatabase('member');

// here autocommit become 1 automatically after Db change. And the previous query rollback automatically

db->query('INSERT INTO memberAccount(CREDIT) VALUES (150)');
db->query('COMMIT');

Whenever i’m trying to change the database then the autocommit value becomes 1 and its rollback my previous query. How to do transactions while changing the db between queries in same server?

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s