fatrbaby/knob 问题修复 & 功能扩展

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

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

fatrbaby/knob

Composer 安装命令:

composer require fatrbaby/knob

包简介

A simple, lightweight database query builder inspired by Laravel.

README 文档

README

Knob is a simple, lightweight database query builder inspired by Laravel. It provides a fluent, chainable interface for building SQL queries across multiple database drivers.

Requirements

  • PHP 8.2+
  • PDO extension

Supported Databases

  • MySQL / MariaDB
  • PostgreSQL
  • SQLite
  • SQL Server

Installation

composer require fatrbaby/knob

Quick Start

use Knob\Knob;

// Set PDO connection (driver is auto-detected)
Knob::using($pdo);

// Build queries
$users = Knob::table('users')
    ->select('id', 'name', 'email')
    ->where('status', 'active')
    ->orderBy('created_at', 'DESC')
    ->limit(10)
    ->get();

// Insert
Knob::table('users')->insert([
    ['name' => 'Alice', 'email' => 'alice@example.com'],
]);

// Update
Knob::table('users')
    ->where('id', 1)
    ->update(['name' => 'Updated Name']);

// Delete
Knob::table('users')->where('id', 1)->delete();

// Aggregates
$count = Knob::table('users')->count();

OpenSpec

This project uses OpenSpec for spec-driven changes.

  • Workflow entry: openspec/README.md
  • Baseline specs: openspec/specs/
  • Active proposals: openspec/changes/

Testing

Run the default test suite:

make test

MySQL, PostgreSQL, and SQL Server smoke tests are optional and only run when their DSN environment variables are configured:

cp .env.example .env

Fill in the database credentials in .env, then run:

make smoke-mysql
make smoke-pgsql
make smoke-sqlsrv

Use make smoke to run all configured database smoke tests. Empty DSNs are skipped.

License

Apache-2.0

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2026-05-27

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固