$user = User::find(3); $user->first_name = 'Dan'; $user->save();
UPDATE users SET first_name='Dan' WHERE id=3;or it will make two querys, by first getting the row and then updating it?
SELECT * FROM users WHERE id=3; UPDATE users SET first_name='Dan' WHERE id=3;
//This time we don't get first_name's or any other field's value, we only set it's value //So we only should have $user = User::find(3); $user->first_name = 'Dan'; //Only one query: UPDATE users SET first_name='Dan' WHERE id=3; $user->save();
//This time we do get first_name's value and after that we set a new value for it //So now we should have $user = User::find(3); //First query: SELECT * FROM users WHERE id=3; $somevar = $user->first_name; $user->first_name = 'Dan'; //Second query: UPDATE users SET first_name='Dan' WHERE id=3; $user->save();
It looks like you're new here. If you want to get involved, click one of these buttons!