When does a MySQL Query actually execute in PHP?

Posted by MJB on Stack Overflow See other posts from Stack Overflow or by MJB
Published on 2010-03-22T16:09:19Z Indexed on 2010/03/22 16:11 UTC
Read the original article Hit count: 270

Filed under:
|

This sounds like a really simple question, but I am new to PHP. If I have a statement like this:

$r =& $db->query("insert into table (col1, col2) values (10, 20)");

Do I have to still execute it, or does it get executed when I reference it? I have another case where I have a select query, which seems logically to run only when I call fetchrow, but the code I am presented with (to fix) does not call execute or fetch.I would have expected it to, so I cannot tell if it is just that I don't get it, or that the missing execute statement is the problem. It also does not insert the record, but it does not throw an error I can find.

Also, I am a little confused by the =& notation. I looked it up on google, and found a few mentions of it, but I am still not clear on it.

Thanks.

© Stack Overflow or respective owner

Related posts about php

Related posts about mysql