这不是问题,只是我的好奇心。以下哪种方式最适合从表中获取事件行并检查用户是否是其所有者?
我见过类似的问题,但我想了解为什么一个比另一个快?
$query = mysql_query("SELECT id FROM event WHERE uid='".$user_id."' AND event_id = '".$id."'");
$checkCreator = mysql_num_rows($query);
if ($query > 0) {
//user is the event owner
}
或者
$query = mysql_query("SELECT uid FROM event WHERE event_id='".$event_id."'");
$checkCreator = mysql_fetch_array($query);
if ($checkCreator['uid'] == $user_id) {
//user is the event owner
}