php pdo insert again if row columns are different

Some sort of id,
Timestamp
First name,
Last name,
Email
Weight

User may change any column
Want timestamp recorded if any column altered





User may change first
LVL 1
rgb192Asked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
Ray PaseurConnect With a Mentor Commented:
In that case I would just INSERT the new row every time.  When you SELECT you can ORDER BY the timestamp column DESC with LIMIT 1 and you will always get the latest values.
0
 
Ray PaseurCommented:
If any column is altered the TIMESTAMP column will be altered.  If there are no changes to the row, the TIMESTAMP column will not be altered. That is expected MySQL behavior.

It follows that if you create an UPDATE query that tries to UPDATE a row with column "weight" = 150 and the row already had column "weight" = 150, no update will occur.  I have never tested this, but I expect that you could experiment with a DATETIME column to cause an update to occur every time.  Just a thought, ~Ray
0
 
rgb192Author Commented:
I literally want to 'insert again' if results are different

for example if user changes their weight (int) or email (varchar)  then they get another row.


This is not an update.
0
 
rgb192Author Commented:
This would insert into the needed first row every time.
0
 
Ray PaseurCommented:
Thanks for the points and thanks for using EE, ~Ray
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.