Hızlı yanıt: kod örneği
Lets try to understand your code and how it works:A variable has a collection of rows which are returned by a query. The size of the collection can be from 0 to n.This line fetch the first element from the collection. If the collection is empty it will return .It can be decoupled in the following steps:
$results = $connectToDb->fetch("SELECT * FROM customer");
$results
$resultsArray = $results->fetch_assoc();
NULL
while($row = $results->fetch_assoc()){}
- Calculate and return array with elements or NULL.
$row = $results->fetch_assoc()
- Substitute in
$row = $results->fetch_assoc()
with gotten value and get the following statements:while
orwhile(array(with elements))
.while(NULL)
- If it's it resolves the while condition in
while(array(with elements))
and allow to perform an iteration.True
- If it's it resolves the while condition in
while(NULL)
and exits the loop.False