1

Every time I am updating a data in MYSQL, the created_at updates the same time as updated_at. I only want updated_at to be the only ones to be updating. is there anyway I can do this?

Laravel 4.2 - 5.1

here is my code in controller

public function read(){ $response = array(); $data = Docs::find(Input::get("id")); if($data){ $data -> read = "1"; $data -> save(); $response["success"] = TRUE; } return Response::json($response); } 
3
  • 2
    Could you show us the code you use to update the data? Sounds like you are doing something wrong there. Commented Jun 27, 2015 at 6:24
  • 2
    Looks like your table, in the database, is a table who has the setting to to be a timestamp which updates on update. Commented Jun 27, 2015 at 7:04
  • 2
    Woops, ment column, your created_at column might be setup to automatically update when the table data updates. Commented Jun 27, 2015 at 7:10

1 Answer 1

2

Since there is nothing wrong with your code, it might be a problem with how the database was setup.

A common mistake is that the created_at column, in the database, is setup to be a timestamp that automatically updates when the table data changes.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.