Is there a faster way to perform this most simple query in terms of server load? I don't think I've ever tried anything other than this method:
$sql = 'SELECT thing FROM table WHERE id="' . $id . '" ';
$res = mysql_query($sql);
$row = mysql_fetch_array($res);
$thing = $row[0];
Any way to improve this?
Performance wise you can create an index on id
if not already done.
Security wise you are open to SQL-injection attack, use prepares statements instead.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.