Example #1
0
 public function save()
 {
     $parameters = array('name' => $this->name, 'password' => $this->password, 'admin' => $this->admin);
     $query = 'INSERT INTO Forum_User (name, password, admin) VALUES (:name, :password, :admin) RETURNING id';
     $row = parent::queryWithParametersLimit1($query, $parameters);
     $this->id = $row['id'];
 }
Example #2
0
 public function save()
 {
     $parameters = array('title' => $this->title, 'forum_group_id' => $this->forum_group_id, 'creator' => $this->creator);
     $query = 'INSERT INTO Topic (title, forum_group_id, creator) VALUES (:title, :forum_group_id, :creator) RETURNING id';
     $row = parent::queryWithParametersLimit1($query, $parameters);
     $this->id = $row['id'];
 }
Example #3
0
 public function save()
 {
     $parameters = array('author' => $this->author, 'message' => $this->message, 'topic_id' => $this->topic_id);
     $query = 'INSERT INTO Forum_Message (author, posted, message, topic_id) VALUES (:author, NOW(), :message, :topic_id) RETURNING id';
     $row = parent::queryWithParametersLimit1($query, $parameters);
     $this->id = $row['id'];
 }
Example #4
0
 public function checkForDuplicate()
 {
     $errors = array();
     $parameters = array('user_id' => $this->user_id, 'forum_group_id' => $this->forum_group_id);
     $query = 'SELECT * FROM Group_Member WHERE user_id = :user_id AND forum_group_id = :forum_group_id LIMIT 1';
     $row = parent::queryWithParametersLimit1($query, $parameters);
     if ($row) {
         $errors[] = "Käyttäjä on jo ryhmän jäsen";
     }
     return $errors;
 }
Example #5
0
 public static function findByID($id)
 {
     $row = parent::queryWithParametersLimit1('SELECT * FROM Forum_Group WHERE id = :id LIMIT 1', array('id' => $id));
     return new Group(array('id' => $row['id'], 'name' => $row['name'], 'creator' => $row['creator']));
 }