コード例 #1
0
ファイル: Database.php プロジェクト: keeto/chill
 public function saveDoc($doc, $opts = array())
 {
     if (is_string($doc)) {
         $doc = json_decode($doc, true);
     }
     if (!isset($doc["_id"])) {
         $doc["_id"] = Chill::getUuid();
     }
     $response = $this->put($doc["_id"], $opts, json_encode($doc));
     if ($response->body->ok) {
         $doc["_rev"] = $response->body->rev;
         $data = new Chill_Document($this, $doc, false);
     } else {
         $data = false;
     }
     return $data;
 }
コード例 #2
0
ファイル: Chill.php プロジェクト: keeto/chill
 static function getUuid()
 {
     if (empty(Chill::$UUIDS)) {
         $response = Chill::$Reader->get(Chill::$H, "_uuids", array(), array("count" => "20"));
         Chill::$UUIDS = $response->body->uuids;
     }
     if (empty(Chill::$UUIDS)) {
         $uuidarr = array();
         for ($i = 0; $i < 21; $i++) {
             array_push($uuidarr, Chill::createUuid());
         }
         Chill::$UUIDS = $uuidarr;
     }
     //var_dump(Chill::$UUIDS);
     return array_shift(Chill::$UUIDS);
 }
コード例 #3
0
ファイル: ChillBase.php プロジェクト: keeto/chill
 public function __construct()
 {
     if (!Chill::$Reader) {
         Chill::$Reader = new Chill_Reader();
     }
 }