KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
This is a pretty simple question and I'm assuming the answer is "It doesn't matter" but I have to ask anyway... I have a generic sql statement built in PHP: $sql = 'SELECT * FROM `users` WHERE `id` IN(' . implode(', ', $object_ids) . ')'; Assuming prior validity checks ( $object_ids is an array with at least 1 item and all numeric values), should I do the following instead? if(count($object_ids) == 1) { $sql = 'SELECT * FROM `users` WHERE `id` = ' . array_shift($object_ids); } else { $sql = 'SELECT * FROM `users` WHERE `id` IN(' . implode(', ', $object_ids) . ')'; } Or is the overhead of checking count($object_ids) not worth what would be saved in the actual sql statement (if any at all)?
Tags (comma-separated)
Save Edits
Cancel