0
你好,我有這個原始查詢這給了我他們的位置距離CakePHP的根據緯度和長途從數據庫中獲取結果
SELECT *,(3959 * ACOS(COS(RADIANS(42.290763)) * COS(RADIANS(location.lat))
* COS(RADIANS(location.long) - RADIANS(-71.35368)) + SIN(RADIANS(42.290763))
* SIN(RADIANS(location.lat)))) AS distance
FROM `gig_post`
JOIN user_info ON `gig_post`.user_id = user_info.user_id
JOIN location
ON location.`gig_post_id`=`gig_post`.gig_post_id
ORDER BY distance;
這裏是我的CakePHP的查詢這是越來越從多個表的結果產生。現在
public function getAllGigPosts(){
$this->Behaviors->attach('Containable');
return $this->find('all', array(
'contain' => array(
'User','UserInfo', 'GigPostAndCategory.Category','Location','GigPostAndCalender'
),
'conditions' => array(
'GigPost.active' => 1
//'OrderGigPost.request' => 0
),
'order' => 'GigPost.gig_post_id DESC',
'recursive' => 0
));
}
在這個cakephp
查詢我要實現它具有式給我的距離以及在查詢是原始查詢。我不知道如何在當前的cakephp
包含查詢中插入原始查詢。
** https://開頭stackoverflo w.com/questions/11535808/how-to-implement-distance-queries-in-cakephp** – ndm