Skip to content

Commit c470344

Browse files
authored
Update index.php
1 parent 136659c commit c470344

File tree

1 file changed

+57
-1
lines changed

1 file changed

+57
-1
lines changed

tests/index.php

+57-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,60 @@
11
<?php
22
require '../vendor/autoload.php';
33

4-
//(new \zyimm\query\QueryBuilderServiceProvider())->register();
4+
/**
5+
1.目前支持条件操作符
6+
'=',
7+
'<>',
8+
'>',
9+
'>=',
10+
'<',
11+
'<=',
12+
'like',
13+
'full_like',
14+
'in',
15+
'not_in',
16+
'between',
17+
'not_between'
18+
**/
19+
use Illuminate\Support\Facades\DB;
20+
use zyimm\query\build\QueryWhere;
21+
/**
22+
* @var QueryWhere $build
23+
*/
24+
$build = app('QueryWhere');
25+
26+
//提交过来数据
27+
$data = [
28+
'log_id' => 20,
29+
'user_id'=> 'zyimm',
30+
'user_name' => "zyimm,12"
31+
];
32+
33+
//配置数据库字段查询操作
34+
$condition =[
35+
'=' => [
36+
'log_id'
37+
],
38+
'not_in' => [
39+
'user_id'
40+
],
41+
'between' => [
42+
'user_name'
43+
],
44+
'full_like' => [
45+
'user_id'
46+
],
47+
'<>' => [
48+
'user_id'
49+
],
50+
'>' => [
51+
'user_id'
52+
]
53+
];
54+
DB::enableQueryLog();
55+
//model
56+
\App\Models\Log::query()
57+
->where(function ($query) use ($build, $data, $condition){
58+
$build->buildQueryWhere($data ,$condition, $query);
59+
})->get();
60+
dd(DB::getQueryLog());

0 commit comments

Comments
 (0)