db raw update laravel 1

db raw update laravel

DB::table('users')->where('user_id',1)->update(array(
                                 'username'=>$username,
));

Here is what the above code is Doing:
1. We’re using the DB facade to access the database.
2. We’re using the table() method to access the users table.
3. We’re using the where() method to find the user with the user_id of 1.
4. We’re using the update() method to update the username column with the value of $username.

Similar Posts