View Single Post
Old 06-19-2009, 03:11 AM   #4 (permalink)
Village Idiot
Wizard
Top Contributor 
 
Village Idiot's Avatar
 
Join Date: Sep 2007
Posts: 1,299
Thanks: 17
Village Idiot is on a distinguished road
Default

Quote:
Originally Posted by 9three View Post
Got it. Thank you, I've added the (int).

PHP Code:
$result $mysqli->query("SELECT ID FROM products WHERE ID = '$input_id'"); 
Just a style tip, don't capitalize field names. Generally the only thing that should be caps are keywords. It does not really matter for small stuff like this, but it pays off when you have really big queries.

Quote:
Originally Posted by 9three View Post
I'm trying to re factor the loops because if I (for example)4,000 items then the function would need to place all those IDs into an array and then sort through it. I would imagine it would slow down the application a lot.
Doing it in the script would slow it immensely. SQL can sort though tens of thousands of rows in under a second, doing it in PHP would be slow and memory intensive. A database that returns too much or too little is not doing its job, a good query should return exactly what you need to complete the process at hand. Let SQL do as much of the data processing as possible.
__________________

Village Idiot is offline  
Reply With Quote