public function leave()
 {
     // get nickname to say good bye.
     $user = User::neo()->where(User::get_login_id())->find();
     // get all blog ids to delete comments
     $blogs = Blog::neo()->select('id')->where('user_id = ?', User::get_login_id())->find('all');
     $blog_ids = extract_property($blogs, 'id');
     // delete blog_comment, blog, and user
     Context::get('db')->start_transaction();
     BlogComment::neo()->where('blog_id ' . Query::id_condition($blog_ids))->delete();
     Blog::neo()->where('user_id = ?', User::get_login_id())->delete();
     User::neo()->where(User::get_login_id())->delete();
     Context::get('db')->commit();
     $user->logout();
     $this->redirect_to('/user/leave_success/' . $user->nickname);
 }
 /**
  * show list
  */
 public function index($page = '1')
 {
     $page_size = 5;
     // page size
     $offset = ($page - 1) * $page_size;
     $input_keyword = _get('input_keyword');
     $where = array();
     if (!is_blank($input_keyword)) {
         $where[] = "(blog.subject like '%" . Context::get('db')->escape_string($input_keyword) . "%'" . " OR blog.content like '%" . Context::get('db')->escape_string($input_keyword) . "%'" . " OR user.nickname like '%" . Context::get('db')->escape_string($input_keyword) . "%')";
     }
     $where = implode(' AND ', $where);
     // get id(s) in the page
     $blogs = Blog::neo()->join('user')->select('blog.id')->where($where)->limit($offset, $page_size)->find('all');
     $ids = extract_property($blogs);
     // get blogs in the page
     $this->blogs = Blog::neo()->join('user')->join('blog_comment')->order('blog.id DESC')->where($ids)->find('all');
     $this->paging = new Paging(Blog::neo()->count(), $page_size, "/blog/index/<page>?input_keyword={$input_keyword}", $page);
 }
 public function testObjectsWithPartiallyMissingIndex()
 {
     $this->objects[0]->id = 3;
     unset($this->objects[1]->id);
     $expected = array(3 => 'Foo', 4 => 'Bar');
     $this->assertEquals($expected, extract_property($this->objects, "name", "id"));
 }