vollborn/local-db 问题修复 & 功能扩展

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

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

vollborn/local-db

Composer 安装命令:

composer require vollborn/local-db

包简介

README 文档

README

LocalDB is a small package to read and write JSON files in a Laravel Eloquent like style.
It was originally developed for small web servers that cannot connect to classic databases.


Installation

This package ist available via composer.

composer require vollborn/local-db

Configuration

Set the base path

In the base path all json files are stored. The default value is ../storage/local-db.

You can change it if you need to:

LocalDB::setBasePath(<your path>);

Register a table

Every table or json file needs to be registered beforehand.

LocalDB::table('test', static function (Table $table) {
    $table->int('int')->autoincrements();
    $table->array('array')->nullable();
    $table->boolean('boolean');
    $table->float('float');
    $table->string('string');
});

As you can see, there are multiple data types available:

Name Function
Integer int
Array array
Boolean boolean
Float float
String string

In addition, integers can have autoincrements.
All data types can also be nullable.


Usage

Create data

LocalDB::query('test')->create([
    'float' => 1.00,
    'string' => null,
    'boolean' => false,
    'array' => []
]);

Get data

You can either get all data...

LocalDB::query('test')->get();

or just the first entry...

LocalDB::query('test')->first();

The data can also be filtered.

LocalDB::query('test')->where('float', '=', 1.00)->get();

Available operators:

  • =
  • !=
  • <
  • >
  • <=
  • >=

Furthermore, the data can be ordered.

// ascending
LocalDB::query('test')->orderBy('float')->get();

// descending
LocalDB::query('test')->orderBy('float', true)->get();

There are some numeric operations available too.

// minimal value
LocalDB::query('test')->min('float');

// maximal value
LocalDB::query('test')->max('float');

// average value
LocalDB::query('test')->avg('float');

// summed value
LocalDB::query('test')->sum('float');

Update data

LocalDB::query('test')
    ->where('boolean', '=', false)
    ->update([
        'boolean' => true
    ]);

Delete data

LocalDB::query('test')
    ->where('boolean', '=', false)
    ->delete();

统计信息

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

GitHub 信息

  • Stars: 3
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-12-29

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固