简体   繁体   中英

How to edit this php check function and add additional?

I've got the following check below which checks if any of strCharID1 , strCharID2 or strCharID3 exist in a table: User_RaceChangeLog and an error message will appear.

$sql  = 'SELECT * FROM User_RaceChangeLog r 
         LEFT OUTER JOIN ACCOUNT_CHAR a 
                    ON ((a.strCharID1 = r.strUserID) 
                    OR (a.strCharID2 = r.strUserID) 
                    OR (a.strCharID3 = r.strUserID)) 
         WHERE a.strAccountID = ?';

if ($db->doQuery($sql, $_SESSION['strAccountID']) > 0)
{
    $this->content = Template::Load('error', 
         array('errmsg' => Template::GetLangVar('NATION_TRANSFER_ERROR_5')));
    return false;
}

What I want to do?

I am trying to add a second check if any of strCharID1,strCharID2,strCharID3 exist in USERDATA table and if Zone column is 253 or 254 to appear the same error message? I tried a lot of ways to achieve this, however, I dont know how to structure my query to get USERDATA info based on ACCOUNT_CHAR table - column strCharID1,strCharID2,strCharID3 ?

It will really appreciated if someone can help me out and just post an example of what I should do. Thanks!

I am guessing USER_DATA has strUserId and zone is a column in USER_DATA table.

$sql  = 'SELECT * FROM User_RaceChangeLog r 
     LEFT OUTER JOIN ACCOUNT_CHAR a 
                ON ((a.strCharID1 = r.strUserID) 
                OR (a.strCharID2 = r.strUserID) 
                OR (a.strCharID3 = r.strUserID)) 
     LEFT OUTER JOIN USER_DATA u 
                ON ((u.strUserID = a.strCharID1) 
                OR (u.strUserID = a.strCharID1) 
                OR (u.strUserID = a.strCharID1)) 
     WHERE a.strAccountID = ?' AND u.zone in (253,254);

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM