Aliases are added to Select queries
This commit is contained in:
parent
f942d45e33
commit
9d9cbea844
20 changed files with 76 additions and 76 deletions
|
@ -15,7 +15,7 @@ class Load extends Method
|
||||||
*/
|
*/
|
||||||
public function load()
|
public function load()
|
||||||
{
|
{
|
||||||
$list = $this->c->DB->query('SELECT id FROM ::users WHERE group_id=?i', [$this->c->GROUP_ADMIN])->fetchAll(PDO::FETCH_COLUMN);
|
$list = $this->c->DB->query('SELECT u.id FROM ::users AS u WHERE u.group_id=?i', [$this->c->GROUP_ADMIN])->fetchAll(PDO::FETCH_COLUMN);
|
||||||
$this->model->list = $list;
|
$this->model->list = $list;
|
||||||
$this->c->Cache->set('admins', $list);
|
$this->c->Cache->set('admins', $list);
|
||||||
return $this->model;
|
return $this->model;
|
||||||
|
|
|
@ -17,7 +17,7 @@ class Load extends Method
|
||||||
$userList = [];
|
$userList = [];
|
||||||
$ipList = [];
|
$ipList = [];
|
||||||
$otherList = [];
|
$otherList = [];
|
||||||
$stmt = $this->c->DB->query('SELECT id, username, ip, email, message, expire FROM ::bans');
|
$stmt = $this->c->DB->query('SELECT b.id, b.username, b.ip, b.email, b.message, b.expire FROM ::bans AS b');
|
||||||
while ($row = $stmt->fetch()) {
|
while ($row = $stmt->fetch()) {
|
||||||
$name = $this->model->trimToNull($row['username'], true);
|
$name = $this->model->trimToNull($row['username'], true);
|
||||||
if (null !== $name) {
|
if (null !== $name) {
|
||||||
|
|
|
@ -23,9 +23,9 @@ class Manager extends ManagerModel
|
||||||
*/
|
*/
|
||||||
public function init()
|
public function init()
|
||||||
{
|
{
|
||||||
$sql = 'SELECT id, cat_name, disp_position
|
$sql = 'SELECT c.id, c.cat_name, c.disp_position
|
||||||
FROM ::categories
|
FROM ::categories AS c
|
||||||
ORDER BY disp_position';
|
ORDER BY c.disp_position';
|
||||||
$this->repository = $this->c->DB->query($sql)->fetchAll(PDO::FETCH_UNIQUE);
|
$this->repository = $this->c->DB->query($sql)->fetchAll(PDO::FETCH_UNIQUE);
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,9 +14,9 @@ class Load extends Method
|
||||||
*/
|
*/
|
||||||
public function load()
|
public function load()
|
||||||
{
|
{
|
||||||
$sql = 'SELECT id, search_for, replace_with
|
$sql = 'SELECT ce.id, ce.search_for, ce.replace_with
|
||||||
FROM ::censoring
|
FROM ::censoring AS ce
|
||||||
ORDER BY REPLACE(search_for, \'*\', \'\')';
|
ORDER BY REPLACE(ce.search_for, \'*\', \'\')';
|
||||||
return $this->c->DB->query($sql)->fetchAll(PDO::FETCH_UNIQUE);
|
return $this->c->DB->query($sql)->fetchAll(PDO::FETCH_UNIQUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ class Refresh extends Method
|
||||||
*/
|
*/
|
||||||
public function refresh()
|
public function refresh()
|
||||||
{
|
{
|
||||||
$stmt = $this->c->DB->query('SELECT id, search_for, replace_with FROM ::censoring');
|
$stmt = $this->c->DB->query('SELECT ce.id, ce.search_for, ce.replace_with FROM ::censoring AS ce');
|
||||||
$search = [];
|
$search = [];
|
||||||
$replace = [];
|
$replace = [];
|
||||||
while ($row = $stmt->fetch()) {
|
while ($row = $stmt->fetch()) {
|
||||||
|
|
|
@ -15,7 +15,7 @@ class Load extends Method
|
||||||
*/
|
*/
|
||||||
public function load()
|
public function load()
|
||||||
{
|
{
|
||||||
$config = $this->c->DB->query('SELECT conf_name, conf_value FROM ::config')->fetchAll(PDO::FETCH_KEY_PAIR);
|
$config = $this->c->DB->query('SELECT cf.conf_name, cf.conf_value FROM ::config AS cf')->fetchAll(PDO::FETCH_KEY_PAIR);
|
||||||
$this->model->setAttrs($config);
|
$this->model->setAttrs($config);
|
||||||
$this->c->Cache->set('config', $config);
|
$this->c->Cache->set('config', $config);
|
||||||
return $this->model;
|
return $this->model;
|
||||||
|
|
|
@ -9,9 +9,9 @@ class CalcStat extends Method
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Пересчитывает статистику
|
* Пересчитывает статистику
|
||||||
*
|
*
|
||||||
* @throws RuntimeException
|
* @throws RuntimeException
|
||||||
*
|
*
|
||||||
* @return Forum
|
* @return Forum
|
||||||
*/
|
*/
|
||||||
public function calcStat()
|
public function calcStat()
|
||||||
|
@ -21,19 +21,19 @@ class CalcStat extends Method
|
||||||
}
|
}
|
||||||
|
|
||||||
$vars = [':fid' => $this->model->id];
|
$vars = [':fid' => $this->model->id];
|
||||||
$sql = 'SELECT COUNT(id) as num_topics, SUM(num_replies) as num_replies
|
$sql = 'SELECT COUNT(t.id) as num_topics, SUM(t.num_replies) as num_replies
|
||||||
FROM ::topics
|
FROM ::topics AS t
|
||||||
WHERE forum_id=?i:fid';
|
WHERE t.forum_id=?i:fid';
|
||||||
|
|
||||||
$result = $this->c->DB->query($sql, $vars)->fetch();
|
$result = $this->c->DB->query($sql, $vars)->fetch();
|
||||||
|
|
||||||
$this->model->num_topics = $result['num_topics'];
|
$this->model->num_topics = $result['num_topics'];
|
||||||
$this->model->num_posts = $result['num_topics'] + $result['num_replies'];
|
$this->model->num_posts = $result['num_topics'] + $result['num_replies'];
|
||||||
|
|
||||||
$sql = 'SELECT last_post, last_post_id, last_poster, subject as last_topic
|
$sql = 'SELECT t.last_post, t.last_post_id, t.last_poster, t.subject as last_topic
|
||||||
FROM ::topics
|
FROM ::topics AS t
|
||||||
WHERE forum_id=?i:fid AND moved_to IS NULL
|
WHERE t.forum_id=?i:fid AND t.moved_to IS NULL
|
||||||
ORDER BY last_post DESC
|
ORDER BY t.last_post DESC
|
||||||
LIMIT 1';
|
LIMIT 1';
|
||||||
|
|
||||||
$result = $this->c->DB->query($sql, $vars)->fetch();
|
$result = $this->c->DB->query($sql, $vars)->fetch();
|
||||||
|
|
|
@ -255,13 +255,13 @@ class Model extends DataModel
|
||||||
|
|
||||||
switch ($this->sort_by) {
|
switch ($this->sort_by) {
|
||||||
case 1:
|
case 1:
|
||||||
$sortBy = 'posted DESC';
|
$sortBy = 't.posted DESC';
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
$sortBy = 'subject ASC';
|
$sortBy = 't.subject ASC';
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$sortBy = 'last_post DESC';
|
$sortBy = 't.last_post DESC';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -270,10 +270,10 @@ class Model extends DataModel
|
||||||
':offset' => ($this->page - 1) * $this->c->user->disp_topics,
|
':offset' => ($this->page - 1) * $this->c->user->disp_topics,
|
||||||
':rows' => $this->c->user->disp_topics,
|
':rows' => $this->c->user->disp_topics,
|
||||||
];
|
];
|
||||||
$sql = "SELECT id
|
$sql = "SELECT t.id
|
||||||
FROM ::topics
|
FROM ::topics AS t
|
||||||
WHERE forum_id=?i:fid
|
WHERE t.forum_id=?i:fid
|
||||||
ORDER BY sticky DESC, {$sortBy}, id DESC
|
ORDER BY t.sticky DESC, {$sortBy}, t.id DESC
|
||||||
LIMIT ?i:offset, ?i:rows";
|
LIMIT ?i:offset, ?i:rows";
|
||||||
|
|
||||||
$this->idsList = $this->c->DB->query($sql, $vars)->fetchAll(PDO::FETCH_COLUMN);
|
$this->idsList = $this->c->DB->query($sql, $vars)->fetchAll(PDO::FETCH_COLUMN);
|
||||||
|
|
|
@ -16,9 +16,9 @@ class Manager extends ManagerModel
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Создает новую модель раздела
|
* Создает новую модель раздела
|
||||||
*
|
*
|
||||||
* @param array $attrs
|
* @param array $attrs
|
||||||
*
|
*
|
||||||
* @return Group
|
* @return Group
|
||||||
*/
|
*/
|
||||||
public function create(array $attrs = [])
|
public function create(array $attrs = [])
|
||||||
|
@ -33,13 +33,13 @@ class Manager extends ManagerModel
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Загрузка списка групп
|
* Загрузка списка групп
|
||||||
*
|
*
|
||||||
* @return Manager
|
* @return Manager
|
||||||
*/
|
*/
|
||||||
public function init()
|
public function init()
|
||||||
{
|
{
|
||||||
if (empty($this->flag)) {
|
if (empty($this->flag)) {
|
||||||
$stmt = $this->c->DB->query('SELECT * FROM ::groups ORDER BY g_id');
|
$stmt = $this->c->DB->query('SELECT g.* FROM ::groups AS g ORDER BY g.g_id');
|
||||||
while ($row = $stmt->fetch()) {
|
while ($row = $stmt->fetch()) {
|
||||||
$this->set($row['g_id'], $this->create($row));
|
$this->set($row['g_id'], $this->create($row));
|
||||||
}
|
}
|
||||||
|
@ -50,9 +50,9 @@ class Manager extends ManagerModel
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Получение модели группы
|
* Получение модели группы
|
||||||
*
|
*
|
||||||
* @param int $id
|
* @param int $id
|
||||||
*
|
*
|
||||||
* @return null|Group
|
* @return null|Group
|
||||||
*/
|
*/
|
||||||
public function get($id)
|
public function get($id)
|
||||||
|
@ -66,7 +66,7 @@ class Manager extends ManagerModel
|
||||||
* Обновляет группу в БД
|
* Обновляет группу в БД
|
||||||
*
|
*
|
||||||
* @param Group $group
|
* @param Group $group
|
||||||
*
|
*
|
||||||
* @return Group
|
* @return Group
|
||||||
*/
|
*/
|
||||||
public function update(Group $group)
|
public function update(Group $group)
|
||||||
|
@ -78,7 +78,7 @@ class Manager extends ManagerModel
|
||||||
* Добавляет новую группу в БД
|
* Добавляет новую группу в БД
|
||||||
*
|
*
|
||||||
* @param Group $group
|
* @param Group $group
|
||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function insert(Group $group)
|
public function insert(Group $group)
|
||||||
|
|
|
@ -45,9 +45,9 @@ class Online extends Model
|
||||||
$deleteU = false;
|
$deleteU = false;
|
||||||
|
|
||||||
if ($detail) {
|
if ($detail) {
|
||||||
$sql = 'SELECT user_id, ident, logged, o_position, o_name FROM ::online ORDER BY logged';
|
$sql = 'SELECT o.user_id, o.ident, o.logged, o.o_position, o.o_name FROM ::online AS o ORDER BY o.logged';
|
||||||
} else {
|
} else {
|
||||||
$sql = 'SELECT user_id, ident, logged FROM ::online ORDER BY logged';
|
$sql = 'SELECT o.user_id, o.ident, o.logged FROM ::online AS o ORDER BY o.logged';
|
||||||
}
|
}
|
||||||
$stmt = $this->c->DB->query($sql);
|
$stmt = $this->c->DB->query($sql);
|
||||||
|
|
||||||
|
|
|
@ -89,9 +89,9 @@ class View extends Action
|
||||||
$vars = [
|
$vars = [
|
||||||
':ids' => $arg->idsList,
|
':ids' => $arg->idsList,
|
||||||
];
|
];
|
||||||
$sql = 'SELECT id, message, poster, posted
|
$sql = 'SELECT w.id, w.message, w.poster, w.posted
|
||||||
FROM ::warnings
|
FROM ::warnings AS w
|
||||||
WHERE id IN (?ai:ids)';
|
WHERE w.id IN (?ai:ids)';
|
||||||
$warnings = $this->c->DB->query($sql, $vars)->fetchAll(PDO::FETCH_GROUP);
|
$warnings = $this->c->DB->query($sql, $vars)->fetchAll(PDO::FETCH_GROUP);
|
||||||
|
|
||||||
$userIds = [];
|
$userIds = [];
|
||||||
|
|
|
@ -55,10 +55,10 @@ class Execute extends Method
|
||||||
$vars = [
|
$vars = [
|
||||||
':key' => $key,
|
':key' => $key,
|
||||||
];
|
];
|
||||||
$sql = 'SELECT search_time, search_data
|
$sql = 'SELECT sc.search_time, sc.search_data
|
||||||
FROM ::search_cache
|
FROM ::search_cache AS sc
|
||||||
WHERE search_key=?s:key
|
WHERE sc.search_key=?s:key
|
||||||
ORDER BY search_time DESC
|
ORDER BY sc.search_time DESC
|
||||||
LIMIT 1';
|
LIMIT 1';
|
||||||
$row = $this->c->DB->query($sql, $vars)->fetch();
|
$row = $this->c->DB->query($sql, $vars)->fetch();
|
||||||
|
|
||||||
|
@ -215,7 +215,7 @@ class Execute extends Method
|
||||||
|
|
||||||
switch ($v->serch_in) {
|
switch ($v->serch_in) {
|
||||||
case 1:
|
case 1:
|
||||||
$whereIdx[] = 'm.subject_match=0';
|
$whereIdx[] = 'sm.subject_match=0';
|
||||||
$whereCJK[] = 'p.message LIKE ?s:word';
|
$whereCJK[] = 'p.message LIKE ?s:word';
|
||||||
$usePCJK = true;
|
$usePCJK = true;
|
||||||
if (isset($vars[':author'])) {
|
if (isset($vars[':author'])) {
|
||||||
|
@ -223,7 +223,7 @@ class Execute extends Method
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
$whereIdx[] = 'm.subject_match=1';
|
$whereIdx[] = 'sm.subject_match=1';
|
||||||
$whereCJK[] = 't.subject LIKE ?s:word';
|
$whereCJK[] = 't.subject LIKE ?s:word';
|
||||||
$useTCJK = true;
|
$useTCJK = true;
|
||||||
if (isset($vars[':author'])) {
|
if (isset($vars[':author'])) {
|
||||||
|
@ -249,7 +249,7 @@ class Execute extends Method
|
||||||
$selectFCJK = 't.id';
|
$selectFCJK = 't.id';
|
||||||
$useTCJK = true;
|
$useTCJK = true;
|
||||||
} else {
|
} else {
|
||||||
$selectFIdx = 'm.post_id';
|
$selectFIdx = 'sm.post_id';
|
||||||
$selectFCJK = 'p.id';
|
$selectFCJK = 'p.id';
|
||||||
$usePCJK = true;
|
$usePCJK = true;
|
||||||
}
|
}
|
||||||
|
@ -290,7 +290,7 @@ class Execute extends Method
|
||||||
$useTIdx = true;
|
$useTIdx = true;
|
||||||
$useTCJK = true;
|
$useTCJK = true;
|
||||||
} else {
|
} else {
|
||||||
$sortIdx = 'm.post_id';
|
$sortIdx = 'sm.post_id';
|
||||||
$sortCJK = 'p.id';
|
$sortCJK = 'p.id';
|
||||||
$usePCJK = true;
|
$usePCJK = true;
|
||||||
}
|
}
|
||||||
|
@ -298,15 +298,15 @@ class Execute extends Method
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$usePIdx = $usePIdx || $useTIdx ? 'INNER JOIN ::posts AS p ON p.id=m.post_id ' : '';
|
$usePIdx = $usePIdx || $useTIdx ? 'INNER JOIN ::posts AS p ON p.id=sm.post_id ' : '';
|
||||||
$useTIdx = $useTIdx ? 'INNER JOIN ::topics AS t ON t.id=p.topic_id ' : '';
|
$useTIdx = $useTIdx ? 'INNER JOIN ::topics AS t ON t.id=p.topic_id ' : '';
|
||||||
$whereIdx = empty($whereIdx) ? '' : ' AND ' . \implode(' AND ', $whereIdx);
|
$whereIdx = empty($whereIdx) ? '' : ' AND ' . \implode(' AND ', $whereIdx);
|
||||||
|
|
||||||
$this->queryIdx = "SELECT {$selectFIdx}, {$sortIdx} FROM ::search_words AS w " .
|
$this->queryIdx = "SELECT {$selectFIdx}, {$sortIdx} FROM ::search_words AS sw " .
|
||||||
'INNER JOIN ::search_matches AS m ON m.word_id=w.id ' .
|
'INNER JOIN ::search_matches AS sm ON sm.word_id=sw.id ' .
|
||||||
$usePIdx .
|
$usePIdx .
|
||||||
$useTIdx .
|
$useTIdx .
|
||||||
'WHERE w.word LIKE ?s:word' . $whereIdx;
|
'WHERE sw.word LIKE ?s:word' . $whereIdx;
|
||||||
|
|
||||||
if ($usePCJK) {
|
if ($usePCJK) {
|
||||||
$this->queryCJK = "SELECT {$selectFCJK}, {$sortCJK} FROM ::posts AS p " .
|
$this->queryCJK = "SELECT {$selectFCJK}, {$sortCJK} FROM ::posts AS p " .
|
||||||
|
|
|
@ -29,10 +29,10 @@ class Index extends Method
|
||||||
$vars = [
|
$vars = [
|
||||||
':pid' => $post->id,
|
':pid' => $post->id,
|
||||||
];
|
];
|
||||||
$sql = 'SELECT w.id, w.word, m.subject_match
|
$sql = 'SELECT sw.id, sw.word, sm.subject_match
|
||||||
FROM ::search_words AS w
|
FROM ::search_words AS sw
|
||||||
INNER JOIN ::search_matches AS m ON w.id=m.word_id
|
INNER JOIN ::search_matches AS sm ON sw.id=sm.word_id
|
||||||
WHERE m.post_id=?i:pid';
|
WHERE sm.post_id=?i:pid';
|
||||||
$stmt = $this->c->DB->query($sql, $vars);
|
$stmt = $this->c->DB->query($sql, $vars);
|
||||||
|
|
||||||
$mesCurWords = [];
|
$mesCurWords = [];
|
||||||
|
@ -73,9 +73,9 @@ class Index extends Method
|
||||||
$vars = [
|
$vars = [
|
||||||
':words' => $allWords,
|
':words' => $allWords,
|
||||||
];
|
];
|
||||||
$sql = 'SELECT word
|
$sql = 'SELECT sw.word
|
||||||
FROM ::search_words
|
FROM ::search_words AS sw
|
||||||
WHERE word IN(?as:words)';
|
WHERE sw.word IN(?as:words)';
|
||||||
$oldWords = $this->c->DB->query($sql, $vars)->fetchAll(PDO::FETCH_COLUMN);
|
$oldWords = $this->c->DB->query($sql, $vars)->fetchAll(PDO::FETCH_COLUMN);
|
||||||
$newWords = \array_diff($allWords, $oldWords);
|
$newWords = \array_diff($allWords, $oldWords);
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ class Load extends Method
|
||||||
*/
|
*/
|
||||||
public function load()
|
public function load()
|
||||||
{
|
{
|
||||||
$list = $this->c->DB->query('SELECT text, image FROM ::smilies ORDER BY disp_position')->fetchAll(PDO::FETCH_KEY_PAIR); //???? text уникальное?
|
$list = $this->c->DB->query('SELECT sm.text, sm.image FROM ::smilies AS sm ORDER BY sm.disp_position')->fetchAll(PDO::FETCH_KEY_PAIR); //???? text уникальное?
|
||||||
$this->model->list = $list;
|
$this->model->list = $list;
|
||||||
$this->c->Cache->set('smilies', $list);
|
$this->c->Cache->set('smilies', $list);
|
||||||
return $this->model;
|
return $this->model;
|
||||||
|
|
|
@ -22,7 +22,7 @@ class Stats extends Model
|
||||||
$this->load();
|
$this->load();
|
||||||
}
|
}
|
||||||
|
|
||||||
list($this->topicTotal, $this->postTotal) = $this->c->DB->query('SELECT SUM(num_topics), SUM(num_posts) FROM ::forums')->fetch(PDO::FETCH_NUM);
|
list($this->topicTotal, $this->postTotal) = $this->c->DB->query('SELECT SUM(f.num_topics), SUM(f.num_posts) FROM ::forums AS f')->fetch(PDO::FETCH_NUM);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,8 +14,8 @@ class Load extends Method
|
||||||
*/
|
*/
|
||||||
public function load()
|
public function load()
|
||||||
{
|
{
|
||||||
$total = $this->c->DB->query('SELECT COUNT(id)-1 FROM ::users WHERE group_id!=0')->fetchColumn();
|
$total = $this->c->DB->query('SELECT COUNT(u.id)-1 FROM ::users AS u WHERE u.group_id!=0')->fetchColumn();
|
||||||
$last = $this->c->DB->query('SELECT id, username FROM ::users WHERE group_id!=0 ORDER BY registered DESC LIMIT 1')->fetch();
|
$last = $this->c->DB->query('SELECT u.id, u.username FROM ::users AS u WHERE u.group_id!=0 ORDER BY u.registered DESC LIMIT 1')->fetch();
|
||||||
$this->model->userTotal = $total;
|
$this->model->userTotal = $total;
|
||||||
$this->model->userLast = $last;
|
$this->model->userLast = $last;
|
||||||
$this->c->Cache->set('stats', [
|
$this->c->Cache->set('stats', [
|
||||||
|
|
|
@ -153,7 +153,7 @@ class Model extends DataModel
|
||||||
':tid' => $this->id,
|
':tid' => $this->id,
|
||||||
':visit' => $this->hasNew,
|
':visit' => $this->hasNew,
|
||||||
];
|
];
|
||||||
$sql = 'SELECT MIN(id) FROM ::posts WHERE topic_id=?i:tid AND posted>?i:visit';
|
$sql = 'SELECT MIN(p.id) FROM ::posts AS p WHERE p.topic_id=?i:tid AND p.posted>?i:visit';
|
||||||
|
|
||||||
$pid = $this->c->DB->query($sql, $vars)->fetchColumn();
|
$pid = $this->c->DB->query($sql, $vars)->fetchColumn();
|
||||||
|
|
||||||
|
@ -175,7 +175,7 @@ class Model extends DataModel
|
||||||
':tid' => $this->id,
|
':tid' => $this->id,
|
||||||
':visit' => $this->hasUnread,
|
':visit' => $this->hasUnread,
|
||||||
];
|
];
|
||||||
$sql = 'SELECT MIN(id) FROM ::posts WHERE topic_id=?i:tid AND posted>?i:visit';
|
$sql = 'SELECT MIN(p.id) FROM ::posts AS p WHERE p.topic_id=?i:tid AND p.posted>?i:visit';
|
||||||
|
|
||||||
$pid = $this->c->DB->query($sql, $vars)->fetchColumn();
|
$pid = $this->c->DB->query($sql, $vars)->fetchColumn();
|
||||||
|
|
||||||
|
@ -243,10 +243,10 @@ class Model extends DataModel
|
||||||
':offset' => ($this->page - 1) * $this->c->user->disp_posts,
|
':offset' => ($this->page - 1) * $this->c->user->disp_posts,
|
||||||
':rows' => $this->c->user->disp_posts,
|
':rows' => $this->c->user->disp_posts,
|
||||||
];
|
];
|
||||||
$sql = 'SELECT id
|
$sql = 'SELECT p.id
|
||||||
FROM ::posts
|
FROM ::posts AS p
|
||||||
WHERE topic_id=?i:tid
|
WHERE p.topic_id=?i:tid
|
||||||
ORDER BY id
|
ORDER BY p.id
|
||||||
LIMIT ?i:offset, ?i:rows';
|
LIMIT ?i:offset, ?i:rows';
|
||||||
$list = $this->c->DB->query($sql, $vars)->fetchAll(PDO::FETCH_COLUMN);
|
$list = $this->c->DB->query($sql, $vars)->fetchAll(PDO::FETCH_COLUMN);
|
||||||
|
|
||||||
|
|
|
@ -42,10 +42,10 @@ class View extends Action
|
||||||
];
|
];
|
||||||
|
|
||||||
if (! $this->c->user->isGuest && '1' == $this->c->config->o_show_dot) {
|
if (! $this->c->user->isGuest && '1' == $this->c->config->o_show_dot) {
|
||||||
$sql = 'SELECT topic_id
|
$sql = 'SELECT p.topic_id
|
||||||
FROM ::posts
|
FROM ::posts AS p
|
||||||
WHERE poster_id=?i:uid AND topic_id IN (?ai:ids)
|
WHERE p.poster_id=?i:uid AND p.topic_id IN (?ai:ids)
|
||||||
GROUP BY topic_id';
|
GROUP BY p.topic_id';
|
||||||
$dots = $this->c->DB->query($sql, $vars)->fetchAll(PDO::FETCH_COLUMN);
|
$dots = $this->c->DB->query($sql, $vars)->fetchAll(PDO::FETCH_COLUMN);
|
||||||
$dots = \array_flip($dots);
|
$dots = \array_flip($dots);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -21,7 +21,7 @@ class IsUniqueName extends Action
|
||||||
':name' => $user->username,
|
':name' => $user->username,
|
||||||
':other' => \preg_replace('%[^\p{L}\p{N}]%u', '', $user->username), //???? что за бред :)
|
':other' => \preg_replace('%[^\p{L}\p{N}]%u', '', $user->username), //???? что за бред :)
|
||||||
];
|
];
|
||||||
$result = $this->c->DB->query('SELECT username FROM ::users WHERE (LOWER(username)=LOWER(?s:name) OR LOWER(username)=LOWER(?s:other)) AND id!=?i:id', $vars)->fetchAll();
|
$result = $this->c->DB->query('SELECT u.username FROM ::users AS u WHERE (LOWER(u.username)=LOWER(?s:name) OR LOWER(u.username)=LOWER(?s:other)) AND u.id!=?i:id', $vars)->fetchAll();
|
||||||
return ! \count($result);
|
return ! \count($result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,9 +9,9 @@ class UsersNumber extends Action
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Подсчет количества пользователей в группе
|
* Подсчет количества пользователей в группе
|
||||||
*
|
*
|
||||||
* @param Group $group
|
* @param Group $group
|
||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function UsersNumber(Group $group)
|
public function UsersNumber(Group $group)
|
||||||
|
@ -23,7 +23,7 @@ class UsersNumber extends Action
|
||||||
$vars = [
|
$vars = [
|
||||||
':gid' => $group->g_id,
|
':gid' => $group->g_id,
|
||||||
];
|
];
|
||||||
$sql = 'SELECT COUNT(id) FROM ::users WHERE group_id=?i:gid';
|
$sql = 'SELECT COUNT(u.id) FROM ::users AS u WHERE u.group_id=?i:gid';
|
||||||
|
|
||||||
return $this->c->DB->query($sql, $vars)->fetchColumn();
|
return $this->c->DB->query($sql, $vars)->fetchColumn();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue