0
如何計算查看量以便我可以根據流行度進行顯示,即誰擁有最高查看次數以便先顯示等。哪個場所的評價最高,它會先顯示,然後是其他顯示。我已經嘗試過,但它不起作用。CakePHP SQL查詢計數以獲得最大查看量
Array
(
[0] => Array
(
[Venue] => Array
(
[id] => 6
)
[Review] => Array
(
[0] => Array
(
[id] => 9
[rating] => 4
[venue_id] => 6
)
[1] => Array
(
[id] => 10
[rating] => 3
[venue_id] => 6
)
[2] => Array
(
[id] => 11
[rating] => 3
[venue_id] => 6
)
)
)
[1] => Array
(
[Venue] => Array
(
[id] => 15
)
[Review] => Array
(
[0] => Array
(
[id] => 16
[rating] => 5
[venue_id] => 15
)
[1] => Array
(
[id] => 17
[rating] => 4
[venue_id] => 15
)
)
)
[2] => Array
(
[Venue] => Array
(
[id] => 17
)
[Review] => Array
(
[0] => Array
(
[id] => 15
[rating] => 4
[venue_id] => 17
)
)
)
[3] => Array
(
[Venue] => Array
(
[id] => 31
)
[Review] => Array
(
)
)
[4] => Array
(
[Venue] => Array
(
[id] => 32
)
[Review] => Array
(
[0] => Array
(
[id] => 18
[rating] => 1
[venue_id] => 32
)
[1] => Array
(
[id] => 19
[rating] => 1
[venue_id] => 32
)
[2] => Array
(
[id] => 20
[rating] => 1
[venue_id] => 32
)
[3] => Array
(
[id] => 21
[rating] => 1
[venue_id] => 32
)
[4] => Array
(
[id] => 22
[rating] => 1
[venue_id] => 32
)
)
)
)
if ($order == 'popularity') {
$order = array('COUNT(Review) DESC');
}
$this->Paginator->settings = array('conditions' => $conditions, 'limit' => 10, 'order' => $order, 'page' => @$data['page']);
$sqql = $this->Paginator->paginate('Venue');
閱讀說明書? http://book.cakephp.org/2.0/en/models/retrieving-your-data.html#find-count另外* always *標記您正在使用的特定CakePHP版本。 – burzum
歡迎來到Stack Overflow!我編輯你的問題來修復一些語法並改進格式。我還將代碼示例縮進了4個空格,以便它能夠正確呈現。我刪除了許多備用空行 - 請參閱編輯幫助以獲取有關格式化的更多信息。請編輯以提供確定具體問題所需的其他詳細信息。祝你好運! – Wtower