简体   繁体   中英

laravel save create the object but not insert in database

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM