FIX выборка интересной точки из непрошедших модерацию

This commit is contained in:
Krivchikov Dmitry 2015-11-23 01:07:05 +03:00
parent 2b88ddc44a
commit b12a1c55b3
1 changed files with 2 additions and 2 deletions

View File

@ -35,10 +35,10 @@ class Point extends Model
public function getRandom() public function getRandom()
{ {
$res = App::DB()->query("SELECT FLOOR(RAND() * COUNT(*)) AS `offset` FROM `" . $this->_tableName_ . "`")->fetch(PDO::FETCH_ASSOC); $res = App::DB()->query("SELECT FLOOR(RAND() * COUNT(*)) AS `offset` FROM `" . $this->_tableName_ . "` WHERE `moderate` = 1")->fetch(PDO::FETCH_ASSOC);
$offset = $res['offset']; $offset = $res['offset'];
$res = App::DB()->query('SELECT `id` FROM ' . $this->_tableName_ . ' LIMIT ' . $offset . ',1;')->fetch(PDO::FETCH_ASSOC); $res = App::DB()->query('SELECT `id` FROM ' . $this->_tableName_ . ' WHERE `moderate` = 1 LIMIT ' . $offset . ',1;')->fetch(PDO::FETCH_ASSOC);
$pointId = $res['id']; $pointId = $res['id'];
return $this->getByPK($pointId); return $this->getByPK($pointId);