Пример #1
0
 public function save()
 {
     $data = ['id' => $this->id, 'title' => $this->title, 'content' => $this->content, 'user_id' => $this->user_id, 'comment_count' => $this->getCommentCount(), 'updated_at' => date(MYSQL_DATE_TIME)];
     $db = DB::instance();
     $this->id = $db->store($data, self::$table);
     return $this->id;
 }
Пример #2
0
 public function save()
 {
     $post = PostModel::get($this->post_id);
     $data = ['id' => $this->id, 'post_id' => $this->post_id, 'user_id' => $this->user_id, 'name' => $this->name, 'message' => $this->message, 'updated_at' => date(MYSQL_DATE_TIME)];
     $db = DB::instance();
     $this->id = $db->store($data, self::$table);
     $post->comment_count = self::getCommentCount($post);
     $post->save();
     return $this->id;
 }
Пример #3
0
 public static function authorize($email, $password)
 {
     Validate::length($email, 1, null, "Заполните поле Email");
     Validate::length($password, 1, null, "Заполните поле Пароль");
     $db = DB::instance();
     $query = $db->getQuery();
     $query->select("*")->from(self::$table)->where("email = '%s'", $email)->where("password = '******'", md5($password));
     $user = $db->queryRow($query);
     Validate::check(!empty($user), "Неверный логин или пароль");
     $_SESSION['user']['id'] = $user['id'];
     return new self($user);
 }
Пример #4
0
 public function delete()
 {
     $db = DB::instance();
     $db->delete(static::$table, "id = '{$this->id}'");
 }