Esempio n. 1
0
 public function delete()
 {
     $bones = new Bones();
     try {
         $bones->couch->delete($this->_id, $this->_rev);
     } catch (SagCouchException $e) {
         $bones->error500($e);
     }
 }
Esempio n. 2
0
 public static function get_instance()
 {
     if (!isset(self::$instance)) {
         self::$instance = new Bones();
     }
     return self::$instance;
 }
Esempio n. 3
0
 public static function get_by_username($username = null)
 {
     $bones = new Bones();
     $bones->couch->login($bones->config->db_admin_user, $bones->config->db_admin_password);
     $bones->couch->setDatabase('_users');
     $user = new User();
     try {
         $document = $bones->couch->get('org.couchdb.user:' . $username)->body;
         $user->_id = $document->_id;
         $user->name = $document->name;
         $user->email = $document->email;
         $user->full_name = $document->full_name;
         return $user;
     } catch (SagCouchException $e) {
         if ($e->getCode() == "404") {
             $bones->error404();
         } else {
             $bones->error500($e);
         }
     }
 }