0

What's the best way to run a mysql query to delete a row if it equals the date in the expire column?

This is my current code:

$sql = "DELETE * FROM table WHERE DATE(expire) = CURDATE()";

$q   = $conn->prepare($sql) or die("failed!");
// Bind the params to the placeholders
$q->execute();
4

2 回答 2

3

这行得通吗?

DELETE FROM TABLE WHERE expire < CURRENT_TIMESTAMP

编辑:正如格雷格所说,我真的看不出你当前的代码有什么问题。我提供的代码可能更能保证您的表已正确清理。

于 2012-10-02T23:13:21.117 回答
0
DELETE FROM TABLE WHERE expire < curDate()

确保您命名了正确的表和正确的字段..

于 2012-10-03T01:15:45.163 回答