IF / ELSE逻辑清理

时间:2015-12-15 17:13:48

标签: php mysql ezsql

我使用的库可以帮助我实现数据库功能。这是一种有效的语法:

if ($memID = $db->get_var("SELECT id FROM users WHERE social_id = ".$_SESSION['user'])) {
   // user found
    $db->query("
          UPDATE users
          SET
            nameF = '".$NameF."',
            nameL = '".$NameL."'
            WHERE id = ".$memID."
          LIMIT 1");
} else {
   // user not found
}

我需要添加额外的支票:

if ($memID = $db->get_var("SELECT id FROM users WHERE social_id = ".$_SESSION['user']) ||
    $memID = $db->get_var("SELECT id FROM users WHERE email = '".$Email."' AND password IS NULL") ||
    ($_COOKIE['socid'] != '' && $memID = $db->get_var("SELECT id FROM users WHERE FIND_IN_SET(social_id, '".$_COOKIE['socid']."'))
 ){

}

但我认为我过于复杂并在此过程中引入错误。我做错了什么?

0 个答案:

没有答案