mirror of
https://github.com/codeguy/php-the-right-way.git
synced 2025-08-06 14:06:34 +02:00
Optimize database interaction code example
This commit is contained in:
@@ -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 %}
|
||||||
|
Reference in New Issue
Block a user