Пример #1
0
 public function postToHome($r)
 {
     $doc = new CouchDB_Document($this->db);
     $doc->title = $r->get('title');
     $doc->type = $r->get('type');
     $doc->description = $r->get('description');
     $doc->save();
     $r->renderRedirect('home');
 }
Пример #2
0
 public function postToDesignDocForm($r)
 {
     $doc = new CouchDB_Document($this->db);
     $doc->_id = '_design/' . $r->get('title');
     if ($r->get('rev')) {
         $doc->_rev = $r->get('rev');
     }
     $views = '{' . trim($r->get('views')) . '}';
     $views = html_entity_decode($views, ENT_COMPAT, 'UTF-8');
     $php = CouchDB::decode_json($views);
     $doc->views = $php->views;
     $doc->save();
     $r->renderRedirect('home');
 }
Пример #3
0
 public static function getDocById($db, $id)
 {
     $data = $db->get_item($id)->getBody(true);
     if (isset($data->_id)) {
         if (isset($data->type) && isset(self::$types_map[$data->type])) {
             $class = self::$types_map[$data->type];
             $doc = new $class($db);
         } else {
             $doc = new CouchDB_Document($db);
         }
         $doc->setData($data);
         return $doc;
     } else {
         return false;
     }
 }
Пример #4
0
 function __construct($db)
 {
     parent::__construct($db);
 }