Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9254259
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:25:22+00:00 2026-06-18T11:25:22+00:00

What I want I want to see which fields on a table was changed

  • 0

What I want

I want to see which fields on a table was changed and save that name into the database under the edit column.

What I have

Currently, not much. Just the standard cakePHP baked edit view and controller. I have done it previously, but not with cakePHP. What I did was retrieve the record, and if it’s different to what the user entered, save the name of the column that was edited in the edit column corresponding to the row.

My Question

Could someone tell me how I would compare user input with what is on the database?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T11:25:24+00:00Added an answer on June 18, 2026 at 11:25 am

    Behaviors like the “Logable” Behavior already do that and store the information separately.
    I advice you to do the same. the “changes” do not necessarily need to be put into the same table. If you feel they do, though, you could make your own “modified” Logable behavior that only creates the “diff” and stores it into a field of your choice on the same record.

    PS: You might also want to take a look at the RevisionBehavior.
    It also contains some diff algorithm.
    Then there is the WhoDidIt behavior which stores the user that last modified the record. In the same table, though. So this combined with the above should do the trick.

    Either way:

    • use callbacks (beforeSave/afterSave) on model itself or (cleaner) as behavior
    • calculate diff
    • store the diff in a separate table or as in your case in an extra table field.

    Actually writing something up here that does the job is pretty straight-forward.
    The voluntary exercise here would be to write it more “generic”. Maybe you want to reuse the same functionality again for other models in the future? Copy-and-paste would be pretty bad style then. The goal here would be to create some generic piece of code you can easily reuse. If your initial code works, try to rewrite it into a generic ChangesBehavior that you can attach to as many models you like. You can take the linked examples or take a look at other behaviors out there to get an idea how to do that.

    Also you can publish your behavior in github/plugins.cakephp and give the community something back again. Maybe others find it useful, too.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I want to see which values from an Excel spreadsheet column don't match
I have a table, prescription , which the fields prescription_id description patient_id pres_date title
I have an asp:table which I want to exported to excel. One of my
I have a table (several actually) that I want to get results from with
I have a table with various fields that can be updated. Let's called it
I would like the users to choose which fields they want to see and
Each file contains 3D points which I want to display. I want to see
I want to create an iOS application which consists of Tamil language. I see
I have a table which has a different colour when you hover over the
If I have a LINQ to SQL table that has a field called say

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.