Conditionally updating the columns PHP/MySQL -
i have embedded mysql statements in php code. next code:
$sql1 = "update labdata1 set date='$d1' sl=1";
i want set column "date" null after 48 hours. tried this:
update labdata1 set date=null when update_time <(now() - interval 2 minute)
but there bug in mysql database keeps update_time
scheme column in mysql null
therefore rather writing procedure in mysql database, want through php code.
kindly allow me know how can through php code?
if want set particular rows update time past 48 hours can this:
$db = new mysqli('localhost', 'username', 'password', 'database'); $sql = 'update labdata1 set date = null update_time >= date_add(update_time, interval -2 day)'; $query = $db->query($sql); if($query->affected_rows > 0) { // update successful! }
php mysql
No comments:
Post a Comment