matrozov/yii2-pro-active-query 问题修复 & 功能扩展

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

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

matrozov/yii2-pro-active-query

Composer 安装命令:

composer require matrozov/yii2-pro-active-query

包简介

Dynamically extensible ActiveQuery class

README 文档

README

This extension provides dynamical customization ActiveQuery filters.

For license information check the LICENSE-file.

Install

Either run

$ php composer.phar require matrozov/yii2-pro-active-query

or add

"matrozov/yii2-pro-active-query": "@dev"

to the require section of your composer.json file.

Usage

Simply add ProActiveQueryTrait trait to your ActiveRecord class and specify ProActiveQuery query-function like this:

class MyClass extends ActiveRecord
{
    use ProActiveQueryTrait;

    ...

    public static function queryMyFunc(ActiveQuery &$query)
    {
        $query->andWhere(['deleted_at' => null']);
    }
}

Now, you can simple selection from database with your filter function:

$items = MyClass::find()->myFunc()->all();

Any function with any parameters with query-prefix can be called from ActiveQuery:

    public static function queryStatusIs(ActiveQuery &$query, $status)
    {
        $query->andWhere(['status' => $status]);
    }
$items = MyClass::find()->statusIs('ready')->all();

You can use additional trait for share query-function between ActiveRecord classes.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-08-01