When does a MySQL Query actually execute in PHP?
- by MJB
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.