0

From Any way to select without causing locking in MySQL? I found a way to implement a select query in a InnoDB table without locking.

The example code given there is the following.

SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED ;
SELECT * FROM TABLE_NAME ;
COMMIT

If I want to implement a similar statement using db_query(), can I do so by issuing three consecutive calls like the following code?

db_query("SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED")
db_query("SELECT * FROM TABLE_NAME")
db_query("COMMIT")

db_query() doesn't support multi-line statements, on Drupal 6.

  • 1
    can I do so by issuing three consecutive calls like this What happened when you tried it? – Clive Jun 13 at 12:41
  • The query worked. But I am not sure if a lock was set or not. I am not that good at mysql/php internals and hence unable to determine whether three different db_query calls will still count as a transaction to mysql. – Kannan Jun 13 at 15:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.