PHP code example of mitirrli / build-query

1. Go to this page and download the library: Download mitirrli/build-query library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

mitirrli / build-query example snippets


use Mitirrli\Buildable\Constant;
use Mitirrli\Buildable\Buildable;

$this->param($params ?? [])
    ->initial(['initial' => 0])
    ->key('avatar')
    ->key('name', Constant::RIGHT)
    ->key('name', Constant::ALL)
    ->inKey('type')
    ->betweenKey('created_at', ['start' => 'create', 'end' => 'end'])
    ->beforeKey('id')
    ->afterKey('id')
    ->unsetKey('initial')
    ->sort('created_at')
    ->result();

use Mitirrli\Buildable\Buildable;

$order = $this
   ->param(array_merge(['update_time' => 'desc'], $params)) //默认更新时间排序
   ->sort(['update_time', 'a.update_time']) //更新时间
   ->sort(['id', 'a.id']) //ID
   ->sort('create_time')
   ->order();