0
在我的应用程序中,我想通过邮编集成一个距离搜索。如何在页面中合并多个查询
$result['zipcode'] = $this->Locations->find('all', array('conditions' => array('plz' => $param)));
if (count($city['Plz']) > 1)
$result['city'] = $this->Locations->find('all', array('conditions' => array('ort' => $city['Stadt']['name'], 'plz !=' => $city['Plz']['zipcode'])));
$this->Locations->virtualFields['distance'] = 'ACOS(SIN(RADIANS(Locations.lat)) * SIN(RADIANS('.$city["Stadt"]["lat"].')) + COS(RADIANS(Locations.lat)) * COS(RADIANS('.$city["Stadt"]["lat"].')) * COS(RADIANS(Locations.lng) - RADIANS('.$city["Stadt"]["lng"].'))) * 6380';
$result['near'] = $this->Locations->find('all', array(
'conditions' => array(
'plz !=' => $param,
'ort !=' => $city['Stadt']['name'],
),
'order' => 'distance ASC'
));
我想显示按邮政编码,以便结果,城市(如城市有许多邮编)及近,所以我就是这么做的。 但现在我想通过蛋糕分页分页这个结果。 是有可能使这些查询得到一个即
$this->Locations->find('all', array('conditions' => array(
'order' => 'RESULTS BY ZIPCODE, RESULTS BY CITY, RESULTS BY MISSMATCH ORDERED BY DISTANCE'
)));
你会如何解决这个问题?
M.
我知道,但有3种请求,我想结合到一个,所以我得到第一个地方邮政编码相匹配,未来地方城市的比赛所有的结果和最后所有其他地方城市和邮政编码并不是为了比赛由距离。 – 2013-05-03 16:14:13
嗯,为什么不在单个查询中执行这些搜索,而是用“过滤”,“排名”结果? – thaJeztah 2013-05-03 16:27:55
我不想手动设置连接,因为此模型在开始创建我的应用程序时具有关联和即时消息。我不知道我是否添加或删除一些关联。有没有一种方法可以在beforeFind中从模型中获取完整查询字符串并退出而无需执行操作? – 2013-05-03 16:41:45