sikker/notnosql 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

sikker/notnosql

Composer 安装命令:

composer require sikker/notnosql

包简介

The SQL-based NoSQL library for PHP -- it's NoSQL, even though it's not!

README 文档

README

What it is:

NotNoSQL is an SQL-based NoSQL key/value store. What that means is that like bigger projects like Couch or Mongo, it stores data using key/value pairs rather than following a table/row/column scheme of traditional SQL-based RDBMS's. It also means that it uses such an SQL-based RDBMS to achieve such functionality.

What it isn't:

NotNoSQL is not intended for large deployments, nor is it intended to be a replacement for dedicated NoSQL-based key/value stores. Rather, it is intended as a quick way to gain data persistency in smaller applications with some concurrency (which would render a .json file dangerous to rely on). Think of it less as a database alternative and more as a flat-file-storage alternative.

Example of usage:

<?php

require 'vendor/autoload.php';
$notnosql = new Sikker\NotNoSQL\NotNoSQL( new PDO('sqlite:database.sqlite3') );
$notnosql->put('foo', 'bar');
echo $notnosql->get('foo') . PHP_EOL;

How it works:

NotNoSQL works by feeding it a PDO object connected to whatever datasource you want to use, be it an sqlite database or an Oracle cluster. It has been tested to work with SQLite3 and MySQL. After that, you just treat it like a json-based key/value store like so:

$notnosql->put('beef.stroganoff.attr.country', ['unknown', 'unknown', 'THE EMPIRE!']);
var_dump($notnosql->get('beef.stroganoff.attr.country'));

Simple, eh?

A thing to keep in mind is that the data is converted to arrays internally, even if it's entered as objects. You will thus always get arrays back out. Feel free to cast/convert them to stdClass objects as you need to after that though!

Contents put into multidimensional arrays like so:

$notnosql->put('beef.stroganoff.chef', 'Bender');
$notnosql->put('beef.stroganoff.customer', 'Fry');

Can be fetched starting from any parent you wish, like so:

$notnosql->get('beef.stroganoff'); // returns ['chef' => 'Bender', 'customer' => 'Fry']

If you want to add items to an existing array, you can use the add method:

$notnosql->put('deliveries', []);
$notnosql->add('deliveries', ['from' => 'Nixon', 'to' => 'Lrrr, Ruler of Omicron Persei 8']);
$notnosql->add('deliveries', ['from' => 'Russia', 'with' => 'love']);

You can delete a key and everything below it with the delete method:

$notnosql->delete('beef.stroganoff');

Although if you just want to delete the contents, you should simply use put to give it an empty value again:

$notnosql->put('deliveries', []);

统计信息

  • 总下载量: 18
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 8
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 8
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: CC-BY-4.0
  • 更新时间: 2018-12-05

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固