
TableUpdate::where는 Eloquent의 where 메서드와 유사하지만, update 쿼리에서만 사용할 수 있습니다.
TableUpdate::where를 사용하여 id가 1인 사용자를 업데이트하려면 다음과 같이 사용할 수 있습니다.
#hostingforum.kr
php
TableUpdate::where('id', 1)->update(['name' => '새로운 이름']);
여러 조건을 사용하여 데이터를 업데이트할 때는 where 메서드를 여러 번 호출하거나 where 메서드에 조건을 여러 개 지정할 수 있습니다.
#hostingforum.kr
php
TableUpdate::where('id', 1)->where('age', 25)->update(['name' => '새로운 이름']);
또는
#hostingforum.kr
php
TableUpdate::where('id', 1)->orWhere('age', 25)->update(['name' => '새로운 이름']);
또한, where 메서드에 조건을 여러 개 지정할 수 있습니다.
#hostingforum.kr
php
TableUpdate::where('id', 1)->where('age', 25)->where('city', '서울')->update(['name' => '새로운 이름']);
또한, where 메서드에 조건을 여러 개 지정할 수 있습니다. where 메서드는 AND 연산자를 사용합니다.
whereOr 메서드는 OR 연산자를 사용합니다.
#hostingforum.kr
php
TableUpdate::where('id', 1)->orWhere('age', 25)->orWhere('city', '서울')->update(['name' => '새로운 이름']);
또한, where 메서드에 조건을 여러 개 지정할 수 있습니다. where 메서드는 AND 연산자를 사용합니다.
whereNot 메서드는 NOT 연산자를 사용합니다.
#hostingforum.kr
php
TableUpdate::where('id', 1)->whereNot('age', 25)->update(['name' => '새로운 이름']);
2025-05-12 14:17