jcshoww/query-collection 问题修复 & 功能扩展

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

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

jcshoww/query-collection

最新稳定版本:1.2.2

Composer 安装命令:

composer require jcshoww/query-collection

包简介

Query collection library for query continious building

README 文档

README

This is query collection library. Query collection could be used as storage-collection for different Query objects, that could be used for DB/API/etc queries dynamic building and manipulation.

Installation

You can install the package via composer:

composer require jcshoww/query-collection

Usage

Create your own query collection and extend it from base QueryCollection class. Add custom basic collection generation in __construct of custom collection.

Look example below:

...
use Jcshoww\QueryCollection\QueryCollection;

class TestQueryCollection extends QueryCollection
{
    /**
     * {@inheritDoc}
     */
    public function __construct(array $fields = [])
    {
        $this->push(new CustomFilter('status', $fields['status']));
    }
}

Create your own custom query objects and extend them from Query class. Look example below:

...
use Jcshoww\QueryCollection\Builder\Builder;
use Jcshoww\QueryCollection\Query\Query;

class Join extends Query
{
    /**
     * {@inheritDoc}
     */
    protected $type = 'Join';

    /**
     * table name
     * 
     * @var string
     */
    protected $table;

    /**
     * owner column to join
     * 
     * @var string
     */
    protected $ownerColumn;
    
    /**
     * foreign column to join
     * 
     * @var string
     */
    protected $foreignColumn;

    /**
     * @param string $table
     * @param string $ownerColumn
     * @param string $foreignColumn
     */
    public function __construct(string $table, string $ownerColumn, string $foreignColumn)
    {
        $this->table = $table;
        $this->ownerColumn = $ownerColumn;
        $this->foreignColumn = $foreignColumn;
    }

    /**
     * @param LaravelBuilder $builder
     * 
     * @return Query
     */
    public function apply(Builder $builder): Query
    {
        $builder->join($this->table, $this->ownerColumn, Where::EQUAL, $this->foreignColumn);
        return $builder;
    }
}

Create your own custom builder objects and extend them from Builder class to customize finishing operations between queries and applied system itself.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-09-21