diff --git a/ground/models/Point.php b/ground/models/Point.php index cff7f8e..a6a25e6 100644 --- a/ground/models/Point.php +++ b/ground/models/Point.php @@ -35,10 +35,10 @@ class Point extends Model 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']; - $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']; return $this->getByPK($pointId);