0
,所以我有以下蒙戈ODM查詢工作得很好:無法向上突破主義ODM查詢
$query = $dm->createQueryBuilder('MainClassifiedBundle:Listing')
->select('id', 'title', 'assets')
->field('somefield0')->equals($somefield)
->field('somefield')->equals($blah)
->field('somefield2')->range($minPrice, $maxPrice)
->field('somefield3')->near($latitude, $longitude)
->getQuery();
$my_data = $query->execute();
但是,如果我試圖打破它像下面這樣:
$query = $dm->createQueryBuilder('MainClassifiedBundle:Listing')
->select('id', 'title', 'assets')
->field('somefield0')->equals($somefield)
->field('somefield')->equals($blah);
if ($propertyType != 'All') {
$query->field('someothercrazyfield')->equals($somethingelse);
$query->field('somefield2')->range($minPrice, $maxPrice)
->field('somefield3')->near($latitude, $longitude)
->getQuery();
$my_data = $query->execute();
我得到一個方法執行不存在的錯誤。
爲什麼?