24小时后价值不会改变

时间:2017-07-17 10:19:20

标签: php mysql

我在这个论坛上找到了代码,然后我就去使用它了。

2017-07-16 11:10:06

这是我的代码。

24小时后它没有变化。

SQL - 时间:

    $sql2 = "SELECT TIME_TO_SEC(TIMEDIFF(NOW(), `dailytime`)) FROM `points` WHERE steamid = '".$steamprofile['steamid']."'";
    $result = $conn->query($sql2);

    if ($result >= 86400) { 
        $sql5 = "UPDATE points SET daily = 1 WHERE steamid = '".$steamprofile['steamid']."'"; 
        $result = $conn->query($sql5);

        $sql6 = "UPDATE points SET `dailytime` = NOW() WHERE steamid = '".$steamprofile['steamid']."'";
        $result = $conn->query($sql6);
    }

节省时间。

它不起作用。

谢谢你们的帮助。

我现在有这个:

public class BaseClass {
    /**
     * Gets the value.
     */
    public final String getValue() {
        // returns something.
    }
}

public class SubClass extends BaseClass {
    /**
     * Gets the value.
     * <p/>
     * The value is meaningless for SubClass.
     */
    @Override // Cannot override final method
    public final String getValue() {
        super.getValue(); // Not overriding implementation, just javadoc
    }
}

1 个答案:

答案 0 :(得分:1)

噢,我们很傻,我们错过了这个明显的错误。

->query()的结果是一个句柄/对象,允许您处理查询生成的结果集。它不会返回结果集本身。

同样使用这些查询,在计算中添加别名可以更轻松地获取结果集中的列。

假设您使用mysqli_,则需要添加一些代码才能获得结果集

$sql2 = "SELECT TIME_TO_SEC(TIMEDIFF(NOW(), `dailytime`)) as the_diff 
        FROM `points` 
        WHERE steamid = '".$steamprofile['steamid']."'";

$result = $conn->query($sql2);

$row = $result->fetch_assoc();

if ($row['the_diff'] >= 86400) { 

    // You can change more than one column in a single query
    // so you only need one UPDATE here
    $sql5 = "UPDATE points SET daily = 1, `dailytime` = NOW()
             WHERE steamid = '{$steamprofile['steamid']}'"; 
    $result = $conn->query($sql5);

}