views:

21

answers:

1

I'm troubleshooting a bug and trying to rule out all possible explanations for why I'm witnessing the behavior that I am. I'm executing a number of MySQL queries in PHP (via CodeIgniter's Active Record class) and one explanation for the behavior that I'm seeing is that the queries aren't being executed synchronously, i.e. that PHP isn't waiting for the query to complete before issuing the next one.

I've always coded under the assumptions that if I insert something into a MySQL table via PHP, and then my next line of code executes a select, the results of my insertion will be available in the next statement. Are there any exceptions to this being the case?

Thanks for helping me preserve my sanity...

+2  A: 

If you select it on the same server, and are using the same session/connection, and you haven't used INSERT DELAYED it should exist indeed, but loadbalanced MySQL servers / implementations / caching may divert SELECT's to other servers or data locations....

Wrikken