So I was wondering what the most efficient way to search a database using WHERE.
If I have var such as
$conditions = "1,3,4,9"
With each of these ints referencing a primary id of a table. So what is the best way to select these rows from mysql.
for($i = 0; $i < strlen($conditions); $i++)
{
if($conditions[$i] == ',')
continue;
$conn->prepare('select * FROM table WHERE id= $i');
}
I was thinking about doing something above however, I am sure there would be more efficient ways then this.
Ps. I know the code above won't work and i wrong it was just an example I wrote up then.
Thanks for the advice.