Пример #1
0
 /**
  * @param CommentsBindingModel $model
  * @throws \Exception
  */
 private static function insert(CommentsBindingModel $model)
 {
     $db = Database::getInstance('app');
     $query = "INSERT INTO comments (comment_text, user_id, date_time) VALUES (?, ?, ?)";
     $result = $db->prepare($query);
     $result->execute([$model->getComment(), $model->getUserId(), $model->getDateTime()]);
 }
Пример #2
0
 /**
  * @param $username
  * @return bool
  * @throws \Exception
  */
 public function exists($username)
 {
     $db = Database::getInstance('app');
     $result = $db->prepare("SELECT id FROM users WHERE username = ?");
     $result->execute([$username]);
     return $result->rowCount() > 0;
 }