有条件地更新PHP / MySQL列

I have embedded the MySQL statements in PHP code. Following is my code:

$sql1 = "UPDATE labdata1 SET Date='$d1' WHERE SL=1";

I want to set the column "Date" to null after 48 hours. What I tried is this:

UPDATE labdata1 
    SET Date=NULL 
    WHEN Update_time <(NOW() - INTERVAL 2 MINUTE)

but there is a bug in MySQL database that keeps Update_time system column in MySQL always NULL

Therefore rather than writing a procedure in MySQL database, I want to do it through PHP code.

Kindly let me know how can do it through PHP code?

If you want to set that particular rows where update time that past 48 hours you can it like this:

$db = new mysqli('localhost', 'username', 'password', 'database');
$sql = 'UPDATE labdata1 
    SET Date = NULL 
    WHERE Update_time >= DATE_ADD(Update_time,  INTERVAL -2 DAY)';
$query = $db->query($sql);
if($query->affected_rows > 0) {
    // update successful!
}