$user = new User(); $user->name = 'John Doe'; $user->email = 'johndoe@example.com'; $user->save();
$user = User::findOne(1); // Assuming the primary key of user is 1 $user->name = 'Jane Doe'; $user->save();In the first example, a new `User` record is created with the name and email attributes set, and then saved to the database using the `save` method. In the second example, an existing `User` record with a primary key of 1 is retrieved using `findOne`, the name attribute is updated, and then the record is saved to the database using the `save` method. Overall, the `save` method is a convenient way to interact with the database and create, update, or delete records as needed.