Welcome Guest, Not a member yet? Register   Sign In
how to prevent timestamp for Update when just Inserting
#1
Question 
(This post was last modified: 04-20-2022, 12:52 AM by Ahmed Haroon.)

how i can prevent ' updated_at ' column to not update when Inserting... while using  ' protected $useTimestamps = true; ' in Model 
when i will display data to management which records updated, then all inserted records will come up because 'updated_at' column is not null.
OR any other better way to timestamping these fields/columns separately with Insert and Update?
regards

Edit: ok, i found the solution while googling:

ALTER TABLE t1
MODIFY created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
MODIFY updated_at DATETIME ON UPDATE CURRENT_TIMESTAMP;

please advise if any other better way.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB