15
15
use chillerlan \Database \{
16
16
Drivers \DriverInterface , ResultInterface
17
17
};
18
- use chillerlan \Logger \LogTrait ;
19
18
use Psr \Log \{
20
- LoggerAwareInterface , LoggerInterface
19
+ LoggerAwareInterface , LoggerAwareTrait , LoggerInterface
21
20
};
22
21
23
22
/**
32
31
* @property \chillerlan\Database\Query\Show $show
33
32
* @property \chillerlan\Database\Query\Truncate $truncate
34
33
* @property \chillerlan\Database\Query\Update $update
35
- *
36
- * @method setLogger(\Psr\Log\LoggerInterface $logger):QueryBuilder
37
34
*/
38
35
class QueryBuilder implements LoggerAwareInterface{
39
- use LogTrait ;
36
+ use LoggerAwareTrait ;
40
37
41
38
protected const STATEMENTS = ['alter ' , 'create ' , 'delete ' , 'drop ' , 'insert ' , 'select ' , 'show ' , 'truncate ' , 'update ' ];
42
39
@@ -57,7 +54,7 @@ class QueryBuilder implements LoggerAwareInterface{
57
54
*/
58
55
public function __construct (DriverInterface $ db , LoggerInterface $ logger = null ){
59
56
$ this ->db = $ db ;
60
- $ this ->log = $ logger ;
57
+ $ this ->logger = $ logger ;
61
58
$ this ->dialect = $ this ->db ->getDialect ();
62
59
}
63
60
@@ -81,19 +78,19 @@ public function __get(string $name){
81
78
* @return \chillerlan\Database\Query\Alter
82
79
*/
83
80
public function alter ():Alter {
84
- return new class ($ this ->db , $ this ->dialect , $ this ->log ) extends StatementAbstract implements Alter{
81
+ return new class ($ this ->db , $ this ->dialect , $ this ->logger ) extends StatementAbstract implements Alter{
85
82
86
83
/** @inheritdoc */
87
84
public function table (string $ tablename ):AlterTable {
88
- return (new class ($ this ->db , $ this ->dialect , $ this ->log ) extends StatementAbstract implements AlterTable{
85
+ return (new class ($ this ->db , $ this ->dialect , $ this ->logger ) extends StatementAbstract implements AlterTable{
89
86
use NameTrait;
90
87
91
88
})->name ($ tablename );
92
89
}
93
90
94
91
/** @inheritdoc */
95
92
public function database (string $ dbname ):AlterDatabase {
96
- return (new class ($ this ->db , $ this ->dialect , $ this ->log ) extends StatementAbstract implements AlterDatabase{
93
+ return (new class ($ this ->db , $ this ->dialect , $ this ->logger ) extends StatementAbstract implements AlterDatabase{
97
94
use NameTrait;
98
95
99
96
})->name ($ dbname );
@@ -106,11 +103,11 @@ public function database(string $dbname):AlterDatabase{
106
103
* @return \chillerlan\Database\Query\Create
107
104
*/
108
105
public function create ():Create {
109
- return new class ($ this ->db , $ this ->dialect , $ this ->log ) extends StatementAbstract implements Create{
106
+ return new class ($ this ->db , $ this ->dialect , $ this ->logger ) extends StatementAbstract implements Create{
110
107
111
108
/** @inheritdoc */
112
109
public function database (string $ dbname ):CreateDatabase {
113
- return (new class ($ this ->db , $ this ->dialect , $ this ->log ) extends StatementAbstract implements CreateDatabase, Query{
110
+ return (new class ($ this ->db , $ this ->dialect , $ this ->logger ) extends StatementAbstract implements CreateDatabase, Query{
114
111
use CharsetTrait, IfNotExistsTrait, NameTrait, QueryTrait;
115
112
116
113
/** @inheritdoc */
@@ -123,7 +120,7 @@ protected function getSQL():array{
123
120
124
121
/** @inheritdoc */
125
122
public function table (string $ tablename ):CreateTable {
126
- return (new class ($ this ->db , $ this ->dialect , $ this ->log ) extends StatementAbstract implements CreateTable, Query{
123
+ return (new class ($ this ->db , $ this ->dialect , $ this ->logger ) extends StatementAbstract implements CreateTable, Query{
127
124
use CharsetTrait, IfNotExistsTrait, NameTrait, QueryTrait;
128
125
129
126
/** @var bool */
@@ -212,7 +209,7 @@ public function text(string $name, $defaultValue = null, bool $isNull = null):Cr
212
209
* @return \chillerlan\Database\Query\Delete
213
210
*/
214
211
public function delete ():Delete {
215
- return new class ($ this ->db , $ this ->dialect , $ this ->log ) extends StatementAbstract implements Delete, Where, BindValues, Query{
212
+ return new class ($ this ->db , $ this ->dialect , $ this ->logger ) extends StatementAbstract implements Delete, Where, BindValues, Query{
216
213
use WhereTrait, QueryTrait, NameTrait {
217
214
name as from;
218
215
}
@@ -229,11 +226,11 @@ protected function getSQL():array{
229
226
* @return \chillerlan\Database\Query\Drop
230
227
*/
231
228
public function drop ():Drop {
232
- return new class ($ this ->db , $ this ->dialect , $ this ->log ) extends StatementAbstract implements Drop{
229
+ return new class ($ this ->db , $ this ->dialect , $ this ->logger ) extends StatementAbstract implements Drop{
233
230
234
231
/** @inheritdoc */
235
232
public function database (string $ dbname ):DropItem {
236
- return (new class ($ this ->db , $ this ->dialect , $ this ->log ) extends StatementAbstract implements DropItem, Query{
233
+ return (new class ($ this ->db , $ this ->dialect , $ this ->logger ) extends StatementAbstract implements DropItem, Query{
237
234
use IfExistsTrait, NameTrait, QueryTrait;
238
235
239
236
/** @inheritdoc */
@@ -246,7 +243,7 @@ protected function getSQL():array{
246
243
247
244
/** @inheritdoc */
248
245
public function table (string $ tablename ):DropItem {
249
- return (new class ($ this ->db , $ this ->dialect , $ this ->log ) extends StatementAbstract implements DropItem, Query{
246
+ return (new class ($ this ->db , $ this ->dialect , $ this ->logger ) extends StatementAbstract implements DropItem, Query{
250
247
use IfExistsTrait, NameTrait, QueryTrait;
251
248
252
249
/** @inheritdoc */
@@ -264,7 +261,7 @@ protected function getSQL():array{
264
261
* @return \chillerlan\Database\Query\Insert
265
262
*/
266
263
public function insert ():Insert {
267
- return new class ($ this ->db , $ this ->dialect , $ this ->log ) extends StatementAbstract implements Insert, BindValues, MultiQuery{
264
+ return new class ($ this ->db , $ this ->dialect , $ this ->logger ) extends StatementAbstract implements Insert, BindValues, MultiQuery{
268
265
use MultiQueryTrait, OnConflictTrait{
269
266
name as into;
270
267
}
@@ -302,7 +299,7 @@ public function values(iterable $values):Insert{
302
299
* @return \chillerlan\Database\Query\Select
303
300
*/
304
301
public function select ():Select {
305
- return new class ($ this ->db , $ this ->dialect , $ this ->log ) extends StatementAbstract implements Select, Where, BindValues, Query{
302
+ return new class ($ this ->db , $ this ->dialect , $ this ->logger ) extends StatementAbstract implements Select, Where, BindValues, Query{
306
303
use QueryTrait, WhereTrait;
307
304
308
305
/** @var bool */
@@ -392,7 +389,7 @@ public function count():int{
392
389
* @return \chillerlan\Database\Query\Show
393
390
*/
394
391
public function show ():Show {
395
- return new class ($ this ->db , $ this ->dialect , $ this ->log ) extends StatementAbstract implements Show{
392
+ return new class ($ this ->db , $ this ->dialect , $ this ->logger ) extends StatementAbstract implements Show{
396
393
397
394
/**
398
395
* @param string $name
@@ -412,7 +409,7 @@ public function __get(string $name){
412
409
413
410
/** @inheritdoc */
414
411
public function databases ():ShowItem {
415
- return new class ($ this ->db , $ this ->dialect , $ this ->log ) extends StatementAbstract implements ShowItem, Query{
412
+ return new class ($ this ->db , $ this ->dialect , $ this ->logger ) extends StatementAbstract implements ShowItem, Query{
416
413
use QueryTrait;
417
414
418
415
/** @inheritdoc */
@@ -426,7 +423,7 @@ protected function getSQL():array{
426
423
/** @inheritdoc */
427
424
public function tables (string $ from = null ):ShowItem {
428
425
429
- $ showTables = new class ($ this ->db , $ this ->dialect , $ this ->log ) extends StatementAbstract implements ShowItem, Where, Query{
426
+ $ showTables = new class ($ this ->db , $ this ->dialect , $ this ->logger ) extends StatementAbstract implements ShowItem, Where, Query{
430
427
use QueryTrait, WhereTrait, NameTrait{
431
428
name as from;
432
429
}
@@ -460,11 +457,11 @@ public function pattern(string $pattern):ShowItem{
460
457
461
458
/** @inheritdoc */
462
459
public function create ():ShowCreate {
463
- return new class ($ this ->db , $ this ->dialect , $ this ->log ) extends StatementAbstract implements ShowCreate{
460
+ return new class ($ this ->db , $ this ->dialect , $ this ->logger ) extends StatementAbstract implements ShowCreate{
464
461
465
462
/** @inheritdoc */
466
463
public function table (string $ tablename ):ShowItem {
467
- return (new class ($ this ->db , $ this ->dialect , $ this ->log ) extends StatementAbstract implements ShowItem, Query{
464
+ return (new class ($ this ->db , $ this ->dialect , $ this ->logger ) extends StatementAbstract implements ShowItem, Query{
468
465
use QueryTrait, NameTrait;
469
466
470
467
/** @inheritdoc */
@@ -485,11 +482,11 @@ protected function getSQL():array{
485
482
* @return \chillerlan\Database\Query\Truncate
486
483
*/
487
484
public function truncate ():Truncate {
488
- return new class ($ this ->db , $ this ->dialect , $ this ->log ) extends StatementAbstract implements Truncate{
485
+ return new class ($ this ->db , $ this ->dialect , $ this ->logger ) extends StatementAbstract implements Truncate{
489
486
490
487
/** @inheritdoc */
491
488
public function table (string $ table ):Truncate {
492
- return (new class ($ this ->db , $ this ->dialect , $ this ->log ) extends StatementAbstract implements Truncate, Query{
489
+ return (new class ($ this ->db , $ this ->dialect , $ this ->logger ) extends StatementAbstract implements Truncate, Query{
493
490
use QueryTrait, NameTrait {
494
491
name as table;
495
492
}
@@ -510,7 +507,7 @@ protected function getSQL():array{
510
507
*/
511
508
public function update ():Update {
512
509
513
- return new class ($ this ->db , $ this ->dialect , $ this ->log ) extends StatementAbstract implements Update, Where, BindValues, MultiQuery{
510
+ return new class ($ this ->db , $ this ->dialect , $ this ->logger ) extends StatementAbstract implements Update, Where, BindValues, MultiQuery{
514
511
use WhereTrait, MultiQueryTrait, NameTrait {
515
512
name as table;
516
513
}
0 commit comments