Optimize database interaction code example

This commit is contained in:
Josh Lockhart
2018-06-20 08:41:39 -04:00
parent c9e5c2659e
commit 8dcaf1e645

View File

@@ -33,7 +33,8 @@ function getAllFoos($db) {
return $db->query('SELECT * FROM table'); return $db->query('SELECT * FROM table');
} }
foreach (getAllFoos($db) as $row) { $results = getAllFoos($db);
foreach ($resultss as $row) {
echo "<li>".$row['field1']." - ".$row['field1']."</li>"; // BAD!! echo "<li>".$row['field1']." - ".$row['field1']."</li>"; // BAD!!
} }
{% endhighlight %} {% endhighlight %}