任何人都要求单个mysql查询进行选择和更新?如果找到了行然后想要更新,否则选择行?
$isTimeout=1;
$uniqueId=$mysqli->real_escape_string($_SESSION['sessionUniqueId']);
$checkSessionSql="SELECT userId FROM user_access_log WHERE
sessionId='$uniqueId' AND isActive=1";
$resultCheckSession=$mysqli->query($checkSessionSql);
if($resultCheckSession->num_rows>0){
if($isTimeout==1){
$updateSessionlog="UPDATE user_access_log SET isActive=0 WHERE sessionId='$uniqueId'";
}else{
while($assoArray=$resultCheckSession->fetch_assoc()){
$userId=$assoArray['userId'];
}
}
}