更新枚举类型

This is my Code:

public function enUser($userID) {
    try {
        $userStatus = "Y";
        $tokenCode = "";
        $sql = ('UPDATE tbl_users SET userStatus = ? AND tokenCode = ? WHERE userID = ?');

        $stmt = $this->conn->prepare($sql);
        $stmt->bindParam(1, $userStatus);
        $stmt->bindParam(2, $tokenCode);
        $stmt->bindParam(3, $userID);
        $stmt->execute();

    } catch (PDOException $e) {
        echo $e->getMessage();
    }
}

This is my enum in database

I have try more to edit it. But in database always appear nothing. I mean in the field 'userStatus' after running the update script, its just value like "" (empty). Can any one help me? Thanks.

1个回答



您的更新必须是:</ p>

 'UPDATE tbl_users SET userStatus = ?,tokenCode  =?  WHERE userID =?
</ code> </ pre>

请参阅逗号而不是 AND </ code> </ p>

并确保< 代码> $ userID </ code>存在于您的数据库</ p>
</ div>中

展开原文

原文

You update must be:

'UPDATE tbl_users SET userStatus = ?, tokenCode = ? WHERE userID = ?

See the comma instead of AND

And make sure that $userID exists in your DB

douningchang3610
douningchang3610 谢谢。 对不起,我忘了..它有工作.. :)
3 年多之前 回复
立即提问
相关内容推荐