承接 joshmcrae/squeal 相关项目开发

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

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

joshmcrae/squeal

最新稳定版本:0.1.6

Composer 安装命令:

composer require joshmcrae/squeal

包简介

A database library for SQLite

README 文档

README

A database library for SQLite.

Installation

composer require joshmcrae/squeal

Usage

Create a database object:

<?php

use Squeal\Database;

// File
$db = Database::fromFile('path/to/database.db');

// In-memory (useful for testing or long-running processes)
$db = Database::inMemory();

Execute a query:

<?php

// Positional parameters
$db->exec('select * from users where id = ?', ['123']);

// Named parameters
$db->exec('select * from users where id = :id', ['id' => '123']);

Conditional SQL fragments based on presence of named parameters:

<?php

$db->exec('
    select  *
    from    users 
    where   active = 1
            [[and type = :type]]
            [[and created_at < :hour_ago]]
', [
    'hour_ago' => time() - 3600
]);

// select * from users where active = 1 and created_at < :hour_ago

Query results:

$results = $db->exec('select * from users');

// Fetch a single record
$results->one();

// Fetch remaining records
$results->all();

// Map remaining records through transformer function
$users = $results->map(fn (array $row) => new User($row['id'], $row['email'], $row['name']));

Query builder:

$results = $db
    ->table('users')
    ->where('active', eq: 1)
    ->where('created_at', lt: time() - 3600)
    ->select(['id', 'email', 'name']);

// Insert record
$db
    ->table('users')
    ->insert([
        'id' => 2,
        'email' => 'john.doe@example.com',
        'name' => 'John Doe',
        'created_at' => time()
    ]);

// Update records
$db
    ->table('users')
    ->where('id', eq: 2)
    ->update([
        'email' => 'jane.doe@example.com',
        'name' => 'Jane Doe',
        'updated_at' => time()
    ]);

// Delete records
$db
    ->table('users')
    ->where('active', eq: 0)
    ->delete();

Query directories:

$dir = $db->directory('reports', '.sql');

// List available queries by name
$queries = $dir->list();

// Execute a query by name
$result = $dir->exec('outstanding_orders', [':as_of' => time()]);

// Use the directory for migrations
$migrated = $dir
    ->asMigrations() // automatically tracks versions
    ->up(); // applies only pending versions

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-04-17

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固