PDO查询,INT不通过绑定进入查询

时间:2015-01-05 08:31:29

标签: php mysql pdo

我对PDO查询非常新,通常使用字符串一切都进入数据库我希望如何更新它但不知何故随机值:运行不会从INT值中减去数据库中的运行状况。而冷却时间已正确更新。 我究竟做错了什么?

$account_health = 100;

if (isset($_POST['action1'])) {
    if($action1 == 2){
        $health_hurt = $account_health/5;
        $health = rand(0,$health_hurt);
        $session_username = $_SESSION['user']['username'];
    // query
    $q = "UPDATE `users` SET `cooldown`=(`cooldown`+'120'),`health`=`health`-':health',`cool`=NOW(),`action`=NOW() WHERE `username`=:username;";
    $st = $db->prepare($q);
        $st->bindValue(':health', $health, PDO::PARAM_INT);
        $st->bindValue(':username', $session_username, PDO::PARAM_STR);
    $start = $st->execute();
    echo "<div align='center'>$health</div>";
    exit;
    }}

数据库:

column - Type - default value
cooldown [INT 255] [0]
health [INT 255] [100]
cool [DATETIME] [0000-00-00 00:00:00]
action [DATETIME] [0000-00-00 00:00:00]

0 个答案:

没有答案