Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

php pdo insert again if row columns are different

Posted on 2013-10-24
5
Medium Priority
?
341 Views
Last Modified: 2013-11-11
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
0
Comment
Question by:rgb192
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 39599315
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
 

Author Comment

by:rgb192
ID: 39599429
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
 
LVL 111

Accepted Solution

by:
Ray Paseur earned 2000 total points
ID: 39600048
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
 

Author Closing Comment

by:rgb192
ID: 39639665
This would insert into the needed first row every time.
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 39639804
Thanks for the points and thanks for using EE, ~Ray
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, we’ll look at how to deploy ProxySQL.
In this article, I’ll talk about multi-threaded slave statistics printed in MySQL error log file.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question