04.07.2014, 19:00
The first one is out of the question. Running multiple queries is never a good idea when you can just run one query to get the same data.
Now, from what I can see the only real difference between the last two is the "cache_get_field_" functions. I would imagine it's faster to just address each row by ID (one cell) rather than a string (a bunch of cells) but I'm not sure how MySQL works internally for that. The second looks way easier to write though and you don't need to mess around with a cache variable to store the value in then assign that to the target (also I noticed that requires using strval/floatstr).
The second option looks like the best method.
Now, from what I can see the only real difference between the last two is the "cache_get_field_" functions. I would imagine it's faster to just address each row by ID (one cell) rather than a string (a bunch of cells) but I'm not sure how MySQL works internally for that. The second looks way easier to write though and you don't need to mess around with a cache variable to store the value in then assign that to the target (also I noticed that requires using strval/floatstr).
The second option looks like the best method.