承接 didslm/sql-builder 相关项目开发

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

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

didslm/sql-builder

最新稳定版本:v1.1.1

Composer 安装命令:

composer require didslm/sql-builder

包简介

A flexible PHP package to build SQL queries using the builder pattern.

README 文档

README

SQL Query Builder is a PHP package designed to help developers construct SQL queries, from the simplest to the most complex, using the builder pattern.

Features

  • Simple and intuitive API.
  • Supports various SQL operations including SELECT, INSERT, UPDATE, and DELETE.
  • Extendable architecture allows for adding more custom query types.
  • Strongly typed components like Where, Join, and OrderBy provide better IDE support and reduce runtime errors.

Installation

Using Composer:

composer require didslm/sql-builder

Usage

Simple SELECT query

<?php

require 'vendor/autoload.php';

use Didslm\QueryBuilder\SelectQueryBuilder;

$query = SelectQueryBuilder::from('users')
    ->select('*')
    ->where('age', 18)
    ->build();

echo $query;  // Outputs: SELECT * FROM users WHERE age = 18

Complex Query

$query = SelectQueryBuilder::from('users')
    ->select('*')
    ->join('posts', 'users.id', 'posts.user_id')
    ->where('users.age', 18, '>')
    ->where('posts.published', true)
    ->build();

echo $query;  // Outputs: SELECT * FROM users JOIN posts ON users.id = posts.user_id WHERE users.age > 18 AND posts.published = true

Grouped conditions

$sql = SelectBuilder::from('users')
    ->where('name', 'John')
    ->and('age', 18)
    ->and('email', 'selimi')
    ->or('name', 'test')
    ->and('email', 'selimi')
    ->build();

echo $sql;  // Outputs: SELECT * FROM users WHERE (name = 'John' AND age = 18 AND email = 'selimi') OR (name = 'test' AND email = 'selimi')

Testing

After cloning the repository and installing the dependencies, you can run the tests with:

vendor/bin/phpunit

Contributing

Pull requests are welcome! For major changes, please open an issue first to discuss what you'd like to change.

Please make sure to update the tests as appropriate.

License

MIT

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-08-30

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固