It returns an "associative array" like a python dictionary. This means your array is indexed by string in my usual case. So I'd suggest it isn't a valid benchmark. If the overhead is "neglectable" and I'm sure the query succeeds and I know there's only a single result, I occasionally do:. For iterative proceedings like a while loop , this just doesn't cut it.
There are alternatives. I suppose it depends on your definition of big. From that benchmark you can see that it is only before you perform upwards of 1,, million fetches that you actually get a measurable difference? Is your database that big? If not, then go with what is easier for you to use which is probably to fetch an associative array. Another point to consider, if it is so big that there is a measurable difference then I would be getting a way from using functions like that all together.
For example, the following query:. It only returns an associative array. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow.
Learn more. Asked 9 years, 8 months ago. Active 4 years, 7 months ago. Viewed 63k times. Below are two methods commonly used in most php codes for fetch mysql data. Which is your choice? Because of this, you can not loop through a resource result twice in the same script before resetting the pointer back to the start position. Thanks to to R. Bradley for the implode idea. Useful for output as an HTML table, for instance. In response to Sergiu's function - implode would make things a lot easier Here's a nifty function to copy a whole table to another table.
If anyone can find a faster way to do this, I'd be glad to know about it Actually, Olivier, you're completely wrong about that, because there's a bug in your sample code. Your browser does not support JavaScript! Please enable it for maximum experience. Thank you. Your description goes here. View Comments. The application essay format depends on what kind of college you are applying to.
0コメント