承接 wtframework/sql 相关项目开发

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

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

wtframework/sql

最新稳定版本:v0.3.1

Composer 安装命令:

composer require wtframework/sql

包简介

What the Framework?! SQL

README 文档

README

This library provides a fluent interface for generating SQL statement strings.

The DBAL library extends this library with a wrapper for PDO.

Installation

composer require wtframework/sql

Documentation

Supported grammars

  • MariaDB
  • MySQL
  • PostgreSQL
  • SQLite
  • TSQL

Supported statements

Example

use WTFramework\SQL\SQL;

echo $stmt = SQL::select()
->from('users')
->where('email_address', 'admin@example.net');
SELECT * FROM users WHERE email_address = ?


After casting the object to a string, like above, the bindings method will return an array of bound parameters.

print_r($stmt->bindings());
Array
(
    [0] => admin@example.net
)

Grammars

The default global grammar is MySQL. Use the static SQL::use method to change this. This will not apply to any existing statements.

use WTFramework\SQL\Grammar;

$stmt1 = SQL::select();

SQL::use(Grammar::TSQL);

$stmt2 = SQL::select();

// $stmt1 will use MySQL, $stmt2 will use TSQL.


The use method can also be used to override the grammar of an individual statement.

$stmt1->use(Grammar::PostgreSQL);

Extending the library

To extend the library you can use the static macro method, passing the new method name and a closure to call. This works for both static and non-static methods. This is available on the SQL class as well as all statement and service classes.

use WTFramework\SQL\SQL;

SQL::macro('count', function (string $table)
{

  return static::select()
  ->column('COUNT(*) AS counter')
  ->from($table);

});
SQL::count('users');

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-01-18

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固