Solved

php pdo insert again if row columns are different

Posted on 2013-10-24
5
332 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 110

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 110

Accepted Solution

by:
Ray Paseur earned 500 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 110

Expert Comment

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

Featured Post

What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

Question has a verified solution.

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

Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

729 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