Back in the day, somewhere along the line I picked up the belief that I needed to write queries in PHP like this:
$query = sprintf("SELECT * FROM table WHERE id = %d",
$id);
$results = mysqli_query($dbh, $query);
or something like that; I just typed this for the post, so please forgive any typos.
What I can't figure is, why am I creating that $query variable at all? Isn't that just an unnecessary use of memory?
How is it different from:
$results = mysqli_query($dbh,
sprintf("SELECT * FROM table WHERE id = %d",
$id)
);