perritu/lean-db 问题修复 & 功能扩展

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

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

perritu/lean-db

最新稳定版本:v1.0.2-rc

Composer 安装命令:

composer require perritu/lean-db

包简介

A simple and light yet powerful ORM for PHP

README 文档

README

A simple and light yet powerful ORM for PHP.

Installation

The best way to install LeanDB is to use Composer:

composer require perritu/lean-db

Direct installation can be done, but it's not yet tested.

Usage

use Perritu\LeanDB\LeanDB;
use Perritu\LeanDB\Connection;
use Perritu\LeanDB\Model;

class MysqlCnn extends Connection
{
  protected static function GetCredentials(): string
  {
    $cUser     = getenv('MYSQL_USER');
    $cPassword = getenv('MYSQL_PASSWORD');
    $cHost     = getenv('MYSQL_HOST');
    $cPort     = getenv('MYSQL_PORT');
    $cDatabase = getenv('MYSQL_DATABASE');
    return "mysql://{$cUser}:{$cPassword}@{$cHost}:{$cPort}/{$cDatabase}";
  }
}

class User extends Model
{
  public const CONNECTION = MysqlCnn::class;
  public const TABLE = 'Users';
  public const FIELDS = [
    'User'     => [LeanDB::ID, null, null, 'User internal ID'],
    'Name'     => [LeanDB::VARCHAR, 30, null, 'User name'],
    'Email'    => [LeanDB::VARCHAR, 100, null, 'User email'],
    'Password' => [LeanDB::CHAR, 64, null, 'User password hash'],
    'Salt'     => [LeanDB::CHAR, 64, null, 'User password salt'],
  ];
  public const PERMS = LeanDB::PERM_ALL;
  public const SOFT_DELETES = true;
  public const TIMESTAMPS = true;
}

User::Create([
  'Name'     => 'John Doe',
  'Email'    => 'git@john.doe',
  'Password' => '4b57da426cca84945d79c2afa37635f0171674264ab03bfd81852e7342a70c56',
  'Salt'     => '0xd488d6befe35b869ccc4be07587846810cc175d488d6befe35b869ccc4be07',
])

$oPdoS = User::Read(['Email' => 'git@john.doe']);
if ($aUser = $oPdoS->fetch()) {
  $cExpectedPassword = $aUser['Password'];
  $cSalt = $aUser['Salt'];
  if (SecretPasswordGestor::Verify($cExpectedPassword, $cSalt)) {
    // ...
  }
}

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Unlicense
  • 更新时间: 2026-04-02

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固