@@ -80,7 +80,6 @@ public function __construct($tableName, Context $context)
8080 $ this ->driver = $ context ->getConnection ()->getSupplementalDriver ();
8181 $ this ->conventions = $ context ->getConventions ();
8282 $ this ->structure = $ context ->getStructure ();
83-
8483 $ this ->delimitedTable = implode ('. ' , array_map ([$ this ->driver , 'delimite ' ], explode ('. ' , $ tableName )));
8584 }
8685
@@ -151,7 +150,6 @@ public function buildSelectQuery($columns = NULL)
151150 } else {
152151 $ prefix = $ joins ? "{$ this ->delimitedTable }. " : '' ;
153152 $ querySelect = $ this ->buildSelect ([$ prefix . '* ' ]);
154-
155153 }
156154
157155 $ queryJoins = $ this ->buildQueryJoins ($ joins );
@@ -405,16 +403,15 @@ protected function buildSelect(array $columns)
405403
406404 protected function parseJoins (& $ joins , & $ query )
407405 {
408- $ builder = $ this ;
409406 $ query = preg_replace_callback ('~
410407 (?(DEFINE)
411408 (?P<word> [\w_]*[a-z][\w_]* )
412409 (?P<del> [.:] )
413410 (?P<node> (?&del)? (?&word) (\((?&word)\))? )
414411 )
415412 (?P<chain> (?!\.) (?&node)*) \. (?P<column> (?&word) | \* )
416- ~xi ' , function ($ match ) use (& $ joins, $ builder ) {
417- return $ builder ->parseJoinsCb ($ joins , $ match );
413+ ~xi ' , function ($ match ) use (& $ joins ) {
414+ return $ this ->parseJoinsCb ($ joins , $ match );
418415 }, $ query );
419416 }
420417
@@ -503,14 +500,11 @@ public function parseJoinsCb(& $joins, $match)
503500 protected function buildQueryJoins (array $ joins )
504501 {
505502 $ return = '' ;
506- foreach ($ joins as $ join ) {
507- list ($ joinTable , $ joinAlias , $ table , $ tableColumn , $ joinColumn ) = $ join ;
508-
503+ foreach ($ joins as list ($ joinTable , $ joinAlias , $ table , $ tableColumn , $ joinColumn )) {
509504 $ return .=
510505 " LEFT JOIN {$ joinTable }" . ($ joinTable !== $ joinAlias ? " {$ joinAlias }" : '' ) .
511506 " ON {$ table }. {$ tableColumn } = {$ joinAlias }. {$ joinColumn }" ;
512507 }
513-
514508 return $ return ;
515509 }
516510
@@ -539,9 +533,8 @@ protected function buildQueryEnd()
539533
540534 protected function tryDelimite ($ s )
541535 {
542- $ driver = $ this ->driver ;
543- return preg_replace_callback ('#(?<=[^\w`"\[?]|^)[a-z_][a-z0-9_]*(?=[^\w`"(\]]|\z)#i ' , function ($ m ) use ($ driver ) {
544- return strtoupper ($ m [0 ]) === $ m [0 ] ? $ m [0 ] : $ driver ->delimite ($ m [0 ]);
536+ return preg_replace_callback ('#(?<=[^\w`"\[?]|^)[a-z_][a-z0-9_]*(?=[^\w`"(\]]|\z)#i ' , function ($ m ) {
537+ return strtoupper ($ m [0 ]) === $ m [0 ] ? $ m [0 ] : $ this ->driver ->delimite ($ m [0 ]);
545538 }, $ s );
546539 }
547540
0 commit comments