
Table::select를 사용하여 데이터를 조회할 때, 조건에 따라 데이터를 필터링하는 방법은 where() 메소드를 사용하는 것입니다.
예를 들어, 'name'이 'Alice'인 데이터만 조회하고 싶다면, 다음과 같이 사용할 수 있습니다.
#hostingforum.kr
php
$data = Table::select()
->where('name', 'Alice')
->execute();
위 코드는 'name'이 'Alice'인 데이터만 조회합니다.
where() 메소드는 여러 조건을 체계적으로 관리할 수 있도록 도와줍니다.
#hostingforum.kr
php
$data = Table::select()
->where('name', 'Alice')
->where('age', '20')
->execute();
위 코드는 'name'이 'Alice'이고 'age'이 20인 데이터만 조회합니다.
또한, where() 메소드는 여러 조건을 AND나 OR로 연결할 수 있습니다.
#hostingforum.kr
php
$data = Table::select()
->where('name', 'Alice')
->orWhere('age', '20')
->execute();
위 코드는 'name'이 'Alice'이거나 'age'이 20인 데이터만 조회합니다.
이러한 방법으로 조건에 따라 데이터를 필터링할 수 있습니다.
2025-05-13 00:05