Esempio n. 1
0
 public function editTopicBody()
 {
     $connection = Connection::getConnection();
     $query = $connection->prepare("UPDATE topic SET body = :body WHERE id = {$this->id}");
     $query->bindValue(':body', $this->body, \PDO::PARAM_STR);
     $query->execute();
 }
Esempio n. 2
0
 private function getDataArr()
 {
     $connection = Connection::getConnection();
     $query = $connection->prepare('SELECT * FROM users WHERE username = :username');
     $query->bindValue(':username', $this->username, \PDO::PARAM_STR);
     $query->execute();
     $this->arr = $query->fetch();
 }
Esempio n. 3
0
 private function getUserTopics()
 {
     $connection = Connection::getConnection();
     $query = $connection->prepare("SELECT id,title FROM topic WHERE user_id = :id");
     $query->bindValue(':id', $this->id, \PDO::PARAM_INT);
     $query->execute();
     $this->data['topics'] = $query->fetchAll();
 }
Esempio n. 4
0
 public function getComments()
 {
     $connection = Connection::getConnection();
     $query = $connection->prepare("SELECT  comments.id, body, parent_id,user_id,topic_id,date,username FROM comments JOIN users ON comments.user_id=users.id WHERE topic_id = '{$this->topic_id}'");
     $query->execute();
     $this->data = $query->fetchAll();
     return json_encode($this->data, JSON_UNESCAPED_UNICODE);
 }
Esempio n. 5
0
 private function getSearchList()
 {
     $connection = Connection::getConnection();
     foreach ($this->regExpArray as $value) {
         $query = $connection->prepare("SELECT * FROM topic WHERE ucase(title) RLIKE ucase(:regulexp)");
         $query->bindParam(':regulexp', $value, \PDO::PARAM_STR);
         $query->execute();
         $this->searchResultArray = $query->fetchAll();
         // Оставлю пока вывод только самых популярных результатов поиска. Когда будет много результатов, можно сделать расширенным.
     }
 }
Esempio n. 6
0
 public function checkUsername()
 {
     $connection = Connection::getConnection();
     $query = $connection->prepare('SELECT username FROM users WHERE username = :username');
     $query->bindParam(':username', $this->username, \PDO::PARAM_STR);
     $query->execute();
     $row_count = $query->fetch();
     if ($row_count == 0) {
         return TRUE;
     }
     $this->message = 'Вообще тут уже есть тело под логином ' . $this->username . ',  ┌( ಠ‿ಠ)┘, придумай чего-нибудь другое (。◕‿◕。)';
     return false;
 }