Save current timestamp in MySQL using PHP mysqi binding

If you have a filed defined and timestamp in MySQL table and you want to insert or update the field using mysqli binding, you can make use of the now() function of MySQL

Example Insert query:
$query = "INSERT INTO my_table VALUES ('text1',now())";
mysqli_query($mysqli, $query);

Example Update query:
$query = "UPDATE my_table SET $topicId=?, $topicName=?, created_date=now()";
$stmt -> bind_param("ss",$topic_name,$topic_desc);
$stmt -> execute();
$stmt -> close();

Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap