承接 sevens/jsondb 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

sevens/jsondb

Composer 安装命令:

composer require sevens/jsondb

包简介

Simple Php Test JSON Database; useful for development mode testing

README 文档

README

  • Simple PHP JSON database for development/testing workflows.
  • Seven JsonDB is developed by Elisha Temiloluwa a.k.a TemmyScope.
  • Built on the Seven Vars utilities for arrays and strings.

Requirements

  • PHP 8.4+
  • Composer

Installation

composer require sevens/jsondb

Usage: Seven\JsonDB\JsonDB HOW-TO

Completely unit tested

  • Valid Input Sample
$data = [
   'name' => 'Random 1',
   'age' => 24, 'password' => 'gHAST_V43SS',
   'nickname' => 'dick & harry'
];
  • Initialization
use Seven\JsonDB\JsonDB;

$db = JsonDB::init($directory, $database);

$table = JsonDB::init($directory, $database, $tblName);

//OR

$table = $db->setTable($tblName);
  • Make database

*** Use this syntax to create a database ***

use Seven\JsonDB\JsonDB;

$newDB = JsonDB::make(string $directory, string $database): bool;
#returns true if successfully created
  • Create Table

*** use this syntax to create a table ***

$schema = [
	'name', 'email', 'password'
];
$table->createTable($table, $schema);

//To use the 'save' method, you need to use a schema when creating a table

Note: id, createdAt and updatedAt are auto-generated fields but you can generate them as well

  • List all databases

*** Use this syntax to list all available databases ***

use Seven\JsonDB\JsonDB;

$newDB = JsonDB::list(string $directory): array;
#returns an array of databases found
  • Count number of databases

*** Use this syntax to count number of available database ***

use Seven\JsonDB\JsonDB;

$newDB = JsonDB::count(string $directory): int;
#returns number of databases found
  • Delete database

*** Use this syntax to delete a database ***

use Seven\JsonDB\JsonDB;

$newDB = JsonDB::delete($directory, $db): bool;
#returns true name if successfully deleted
  • Empty a database; delete database content

*** Use this syntax to delete all contents from a database ***

use Seven\JsonDB\JsonDB;

$newDB = JsonDB::empty($directory, $db): bool;
#returns true on success

Table Operations

  • Generate an Id
use Seven\JsonDB\Table;

$table->generateId(Table::TYPE_STRING || Table::TYPE_INT);

//default is Table::TYPE_STRING
  • Get Last Insert Id
$table->lastInsertId();
  • Save Data In the Table: Only works on tables that were created with schema
//$table->id = 1;
$table->name = 'Elisha Temiloluwa';
$table->email = 'Elisha@gmail.com';
$table->password = hash('SHA256', 'password');
$table->save();
  • Insert Data In the Table
$table->insert([
	'email' => 'sammy@hotmail.com', 'name' => 'Sam Orji', 
	'password' => hash('SHA256', 'passphr4s3'),
]);
  • Find items in the table using certain conditions
$table->find([
	'email' => 'Elisha@gmail.com'
]);
  • Find items in the table using id
$table->findById('38a92f92b1268c64');
  • Find the first or last matching item
$table->first(['email' => 'Elisha@gmail.com']);
$table->last(['email' => 'Elisha@gmail.com']);

Testing

composer install
./vendor/bin/phpunit

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-09-17

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固