I want to execute a query to fetch data from 1000 rows in my database. I have found two methods to do that.
Method 1:
SELECT * FROM user WHERE id=879
and second one which I used to protect myself from SQL Injection was:
Method 2:
<?php
$q="SELECT * FROM user";
$get_res=$dbconn->query($q);
while($set=$get_res->fetch_assoc()) {
if($set['id']==879)
{
//Some task here
}
}
So Which one is faster. I know about SQL prepared Statement.. But I just want to compare these two method.. And if there will be any security flaw in Method2 then Please explain that one also..