File tree Expand file tree Collapse file tree 1 file changed +17
-2
lines changed
Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -704,8 +704,16 @@ public function wherePk($id, $primaryKeyField = null)
704704 */
705705 public function join ($ table , $ on )
706706 {
707+ $ asName = '' ;
708+ if (preg_match ('/^(.+?)\s+(as\s+)?(\w+)$/i ' , $ table , $ res )) {
709+ $ table = $ res [1 ];
710+ $ asName = $ res [3 ];
711+ $ asName = ' AS ' . self ::addTableQuote ($ asName );
712+ }
713+
707714 $ type = 'JOIN ' ;
708- $ table = self ::addPrefix ($ table );
715+
716+ $ table = self ::addPrefix ($ table ) . $ asName ;
709717 $ this ->join [] = compact ('type ' , 'table ' , 'on ' );
710718 return $ this ;
711719 }
@@ -719,8 +727,15 @@ public function join($table, $on)
719727 */
720728 public function leftJoin ($ table , $ on )
721729 {
730+ $ asName = '' ;
731+ if (preg_match ('/^(.+?)\s+(as\s+)?(\w+)$/i ' , $ table , $ res )) {
732+ $ table = $ res [1 ];
733+ $ asName = $ res [3 ];
734+ $ asName = ' AS ' . self ::addTableQuote ($ asName );
735+ }
736+
722737 $ type = 'LEFT JOIN ' ;
723- $ table = self ::addPrefix ($ table );
738+ $ table = self ::addPrefix ($ table ) . $ asName ;
724739 $ this ->join [] = compact ('type ' , 'table ' , 'on ' );
725740 return $ this ;
726741 }
You can’t perform that action at this time.
0 commit comments