私は推進基準で次のクエリを構築しようとしています:
SELECT *
FROM mytable
WHERE facility_id IN (4,7)
GROUP BY housing_id
HAVING COUNT(DISTINCT facility_id) = 2;
推進基準:
$criteria->add(HousingsHousingFacilitiesPeer::HOUSING_FACILITY_ID, $facility_filter, Criteria::IN);
$criteria->addGroupByColumn(HousingsHousingFacilitiesPeer::HOUSING_ID);
$criteria->addHaving(
$criteria->getNewCriterion(
HousingsHousingFacilitiesPeer::HOUSING_ID,
'COUNT(DISTINCT housings_housing_facilities.HOUSING_FACILITY_ID) = 2',
Criteria::CUSTOM
)
);
ただし、クエリは結果を返します。
カスタム条件を正しく使用していますか?