One of the advantages of dynamic languages is that it provides constructions more flexible than the languages of Statics.
while it works in two parts, first it checks fetch_object()
is different from false, if (there is a result of the database) is the second part to which the result assignment is made the variable $clientes
, this occurs due to the rules of precedence of operators of PHP.
The assignment operator is one of the least senior, so the value of while(true or false) is checked and in the positive case the assignment is made.
2- passo 1 - passo
false/ou qualquer coisa
while ($clientes = $resultado->fetch_object()) {
echo $clientes->nome;
echo $clientes->telefone;
}
Which can be interpreted as:
while ($clientes = false) //Não entra no while
true
while ($clientes = $resultado->fetch_object())// Faz a atribuição
Since you’re returning to school now... I advise you to study PDO. :)
– Rafael Withoeft
The steps to perform a query in the database are: 1 - turn the sql string into a query. 2 - Pass this 'result' to the function/method that extracts the bank lines, it is usually necessary to use a for/while to traverse all lines.
– rray
Where can I find this material for PDO studies? Do you know anywhere? ?
– RFL
@Rafaelacioly you don’t need to do this, PDO won’t help you at all. Check the answers, and let us know if there’s anything missing to understand better.
– Maniero
@Rafaelacioly no conselhei PDO por ajudar em sua dúvida, I advised because it is cleaner and supports several databases; http://code.tutsplus.com/pt/tutorials/pdo-vs-mysqliwhich-should-you-use--net-24059 | http://stackoverflow.com/questions/2190737/what-is-Difference-between-mysql-mysqli-and-Pdo
– Rafael Withoeft
@Rafaelacioly You can accept an answer if it solved your problem. You can vote on all the posts on the site as well. Did any help you more? Something needs to be improved?
– Maniero