1

I have problems in keeping the data in the database, the query creates the object for me returns the id of the same, but not the row inserted in the table.

This is the way in which I keep the data:

  $lineup = new lineup(); <br>
  $lineup->user_id = Auth::user()->id;<br>
  $lineup->date = $fecha; <br>
  $lineup->salary_rest = $salary_rest;<br>

   $lineup->save();

PD: I am using laravel 4.2.

5
  • What database are you using? If you look in your config/database.php file it should have 'default' => "something here" Commented May 24, 2016 at 22:48
  • I am working with mysql, but the rare is that in other seccion the save() works fine. Commented May 24, 2016 at 23:14
  • Is any of your code calling DB::beginTransaction() ? and never commiting it? DB::commit()? Commented May 24, 2016 at 23:19
  • It is not just this section, change the way of doing the insert but not serves me. Commented May 24, 2016 at 23:27
  • 1
    Brett thank you very much, I did well review the code and me di account the commit() was commented. Commented May 24, 2016 at 23:52

1 Answer 1

2

There are 2 things to check when items aren't saving to the database.

Check the config/database.php file to ensure it's using the correct database driver.

Secondly ensure if a Transaction is being used that a commit statement is called.

DB::beginTransaction()
// Your code
DB::commit()

Without the commit the changes won't flow through to the database

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.