PHP & MySQL InnoDB: Data not available immediately after insert or update -


i've switched on myisam tables innodb row locking seems better table locking.

problem many of things doing before don't work.

for example, have 1 script recommends items user based on browsing history. done inserting or updating rows recommendations table. actual calculation of recommendation done though sql statement. performing recommendation statement, (in same php script) requesting results of can displayed user right there. myisam worked perfectly, innodb return old results, or no results (if there didn't used any).

also have table acts queue something. use perform , update , select on results of update. again works myisam not innodb.

how can ensure rows inserted or updated in cases? in other cases happy delayed insert or update if speeds query up. in particular cases outlined need immediate. there php command this? or mysql settings?

it sounds having transaction issues since moving innodb http://dev.mysql.com/doc/refman/5.0/en/innodb-transaction-model.html .

unlike myisam, innodb supports database transactions isolate previous sql commands until have committed them special commit sql command. normally, isn't problem since running off of same transaction on same database connection , autocommit enabled default. autocommit feature of mysql automatically commit transaction after data change, such after update. however, guess connecting database multiple times (or perhaps using library doing so) , library or configuration disabling autocommit.

you can test issuing sql commit after update , seeing if problem disappears. if problem, long-term solution depends on libraries using, can enable autocommit again (either through library or removing disabling entry my.cnf or my.ini file) or can preferably start using transactions! there plenty of articles everywhere "mysql data transactions tutorial."

you can enable autocommit via php executing sql set autocommit=1; once before executing rest of sql.

this assumes not having replication issues.


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -