06-19-2009, 03:11 AM
|
#4 (permalink)
|
|
Wizard
Join Date: Sep 2007
Posts: 1,299
Thanks: 17
|
Quote:
Originally Posted by 9three
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
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.
|
|
|
|