1
Hello I am developing a project using the Mysqli extension, and in this taking advantage to use some object-oriented functions! I would like to ask a few questions regarding the data listing, are two questions:
1) Use the foreach() function instead of a while() with the fetch_array() function inside, do you have a faster or slower listing? Because with both I can bring the data, At the moment I’m using the foreach for being faster to type.
2) I use many different table listings on the same page always calling a new SELECT, it would be better to create a function with a SELECT in it so I always reuse it there or it would not change much in terms of performance?
an example of function for queries:
https://www.codigofonte.com.br/codigos/funcao-para-consulta-a-banco-de-dados-mysql-no-php
I appreciate any information.
Hello, I do not know if I could give you my question regarding question 2, I edited the post and put a link, you think if I always call a function (like the link) that makes a SELECT instead of always creating a SELECT manually without the function would be faster in terms of performance? Or theoretically I’m calling a new SELECT the same way within the function?
– Caio Lourençon
Opa @Caiolourençon you still continue performing the various SELECT and calling them again, this solution will leave the more organized code that I believe is an advantage depending on the context.
– André Lins