/** * @param string $key * @param array|string $tags * @return bool */ protected function setTags($key, $tags) { if (!is_array($tags)) { $tags = array($tags); } foreach ($tags as $tag) { try { if (!$this->Couchbase->add($this->tag_prefix . $tag, '"' . addcslashes($key, '\\') . '"')) { $this->Couchbase->append($this->tag_prefix . $tag, ',"' . addcslashes($key, '\\') . '"'); } } catch (\Exception $Exception) { $this->ReportError('Can\'t set tag ' . $tag . ' for key ' . $key, __LINE__); } } return true; }
echo $cb->get("store_strings"); echo "\n\n"; echo "get 'store_floats' => "; echo $cb->get("store_floats"); echo "\n\n"; echo "get 'store_integers' => "; echo $cb->get("store_integers"); echo "\n\n"; echo "--------------------------------------------------------------------------\n"; echo "Append/Prepend Ops\n"; echo "Create a list, start with one item\n"; $cb->set("mylist", "oranges", 30); echo "Add an item...\n\n"; $cb->prepend("mylist", "apples,"); echo "Add an item...\n\n"; $cb->append("mylist", ",bananas"); echo "Add an item...\n\n"; $cb->append("mylist", ",lemons"); echo "Add an item...\n\n"; $cb->append("mylist", ",grapes"); echo "get 'mylist' => "; echo $cb->get("mylist"); echo "\n\n"; echo "--------------------------------------------------------------------------\n"; echo "Store Binary Blobs\n"; // read file echo "\nRead file\n"; $image = file_get_contents('../Binary/lolcat.jpg'); $image_data = base64_encode($image); $cb->set("img", $image_data, 10); $to_save = base64_decode($cb->get("img"));