I have query like:
UPDATE orders SET order_state = $state_id, order_confirmed = now() WHERE order_id = $id LIMIT 1
I'm just wondering if there was a function in php or sql that returned the updated timestamp kind of like insert id.
How about
SELECT now() FROM orders LIMIT 1
or
SELECT now() FROM dual
To avoid second query, use php's DateTime Object
and format it, instead of Mysql's NOW()
$now = new DateTime;
UPDATE orders SET order_state = $state_id, order_confirmed = $now->format('Y-m-d H:i:s') WHERE order_id = $id LIMIT 1
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.