1515use chillerlan \Database \{
1616 Drivers \DriverInterface , ResultInterface
1717};
18- use chillerlan \Logger \LogTrait ;
1918use Psr \Log \{
20- LoggerAwareInterface , LoggerInterface
19+ LoggerAwareInterface , LoggerAwareTrait , LoggerInterface
2120};
2221
2322/**
3231 * @property \chillerlan\Database\Query\Show $show
3332 * @property \chillerlan\Database\Query\Truncate $truncate
3433 * @property \chillerlan\Database\Query\Update $update
35- *
36- * @method setLogger(\Psr\Log\LoggerInterface $logger):QueryBuilder
3734 */
3835class QueryBuilder implements LoggerAwareInterface{
39- use LogTrait ;
36+ use LoggerAwareTrait ;
4037
4138 protected const STATEMENTS = ['alter ' , 'create ' , 'delete ' , 'drop ' , 'insert ' , 'select ' , 'show ' , 'truncate ' , 'update ' ];
4239
@@ -57,7 +54,7 @@ class QueryBuilder implements LoggerAwareInterface{
5754 */
5855 public function __construct (DriverInterface $ db , LoggerInterface $ logger = null ){
5956 $ this ->db = $ db ;
60- $ this ->log = $ logger ;
57+ $ this ->logger = $ logger ;
6158 $ this ->dialect = $ this ->db ->getDialect ();
6259 }
6360
@@ -81,19 +78,19 @@ public function __get(string $name){
8178 * @return \chillerlan\Database\Query\Alter
8279 */
8380 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{
8582
8683 /** @inheritdoc */
8784 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{
8986 use NameTrait;
9087
9188 })->name ($ tablename );
9289 }
9390
9491 /** @inheritdoc */
9592 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{
9794 use NameTrait;
9895
9996 })->name ($ dbname );
@@ -106,11 +103,11 @@ public function database(string $dbname):AlterDatabase{
106103 * @return \chillerlan\Database\Query\Create
107104 */
108105 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{
110107
111108 /** @inheritdoc */
112109 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{
114111 use CharsetTrait, IfNotExistsTrait, NameTrait, QueryTrait;
115112
116113 /** @inheritdoc */
@@ -123,7 +120,7 @@ protected function getSQL():array{
123120
124121 /** @inheritdoc */
125122 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{
127124 use CharsetTrait, IfNotExistsTrait, NameTrait, QueryTrait;
128125
129126 /** @var bool */
@@ -212,7 +209,7 @@ public function text(string $name, $defaultValue = null, bool $isNull = null):Cr
212209 * @return \chillerlan\Database\Query\Delete
213210 */
214211 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{
216213 use WhereTrait, QueryTrait, NameTrait {
217214 name as from;
218215 }
@@ -229,11 +226,11 @@ protected function getSQL():array{
229226 * @return \chillerlan\Database\Query\Drop
230227 */
231228 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{
233230
234231 /** @inheritdoc */
235232 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{
237234 use IfExistsTrait, NameTrait, QueryTrait;
238235
239236 /** @inheritdoc */
@@ -246,7 +243,7 @@ protected function getSQL():array{
246243
247244 /** @inheritdoc */
248245 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{
250247 use IfExistsTrait, NameTrait, QueryTrait;
251248
252249 /** @inheritdoc */
@@ -264,7 +261,7 @@ protected function getSQL():array{
264261 * @return \chillerlan\Database\Query\Insert
265262 */
266263 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{
268265 use MultiQueryTrait, OnConflictTrait{
269266 name as into;
270267 }
@@ -302,7 +299,7 @@ public function values(iterable $values):Insert{
302299 * @return \chillerlan\Database\Query\Select
303300 */
304301 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{
306303 use QueryTrait, WhereTrait;
307304
308305 /** @var bool */
@@ -392,7 +389,7 @@ public function count():int{
392389 * @return \chillerlan\Database\Query\Show
393390 */
394391 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{
396393
397394 /**
398395 * @param string $name
@@ -412,7 +409,7 @@ public function __get(string $name){
412409
413410 /** @inheritdoc */
414411 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{
416413 use QueryTrait;
417414
418415 /** @inheritdoc */
@@ -426,7 +423,7 @@ protected function getSQL():array{
426423 /** @inheritdoc */
427424 public function tables (string $ from = null ):ShowItem {
428425
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{
430427 use QueryTrait, WhereTrait, NameTrait{
431428 name as from;
432429 }
@@ -460,11 +457,11 @@ public function pattern(string $pattern):ShowItem{
460457
461458 /** @inheritdoc */
462459 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{
464461
465462 /** @inheritdoc */
466463 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{
468465 use QueryTrait, NameTrait;
469466
470467 /** @inheritdoc */
@@ -485,11 +482,11 @@ protected function getSQL():array{
485482 * @return \chillerlan\Database\Query\Truncate
486483 */
487484 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{
489486
490487 /** @inheritdoc */
491488 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{
493490 use QueryTrait, NameTrait {
494491 name as table;
495492 }
@@ -510,7 +507,7 @@ protected function getSQL():array{
510507 */
511508 public function update ():Update {
512509
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{
514511 use WhereTrait, MultiQueryTrait, NameTrait {
515512 name as table;
516513 }
0 commit comments