I am trying to understand when is the SQL query actually taking place? For example, lets say I have a code like this:
$stmt = $db->query("SELECT * FROM my_Table"); //Line #1
foreach ($stmt as $row) //Line #2
{
$abc[] = $row['abc'];
}
In the above example, when does the script communicate with the mysql database to get the data? Does it query in Line #1 itself and stores the data to the $stmt variable (or) does it only connects to the database in Line #2 in the foreach() statement?
I know this may sound like a very basic question but I am trying to understand this...