@@ -103,6 +103,7 @@ protected function getDoctrineDriver()
103103 */
104104 private function compileBindings ($ query , $ bindings )
105105 {
106+ var_dump ($ query );
106107 if (count ($ bindings )==0 ){
107108 return [];
108109 }
@@ -113,6 +114,18 @@ private function compileBindings($query, $bindings)
113114 switch (explode (' ' , $ query )[0 ]){
114115 case "select " :
115116 preg_match_all ("/(?:from |join )(?'tables'.*?)(?: (?:on(?:(?!join ).)*|)where(?'attributes'.*)| on|$)/i " ,$ query , $ matches );
117+ $ selects = explode ('from ' , $ query )[0 ];
118+ $ selects = explode (', ' , $ selects );
119+
120+ foreach ($ selects as $ ind ->$ arrSelect ){
121+ $ arrSelects [$ ind ] = trim ($ arrSelect );
122+ if ($ arrSelect = '* ' ){
123+ break ;
124+ }else {
125+
126+ }
127+ }
128+ var_dump ($ selects );
116129 break ;
117130 case "insert " :
118131 preg_match ("/(?'tables'.*) \((?'attributes'.*)\) values/i " ,$ query , $ matches );
@@ -124,8 +137,6 @@ private function compileBindings($query, $bindings)
124137 preg_match ("/(?'tables'.*) where (?'attributes'.*)/i " ,$ query , $ matches );
125138 break ;
126139 }
127-
128-
129140 if (is_array ($ matches ['tables ' ])){
130141 $ desQuery ['tables ' ] = implode ($ matches ['tables ' ], ' ' );
131142 }else if (isset ($ matches ['tables ' ])){
@@ -151,6 +162,7 @@ private function compileBindings($query, $bindings)
151162 return $ bindings ;
152163 }
153164
165+
154166 foreach ($ arrTables as $ tables ){
155167 $ table = $ tables ;
156168
@@ -163,11 +175,17 @@ private function compileBindings($query, $bindings)
163175
164176 $ new_format [$ tables ] = [];
165177 }
166- }
178+ }
167179
168- foreach ($ arrQuery as $ campos ){
169- if (in_array ($ campos , $ arrTables )){
170- if ($ campos !=$ table ) $ table = $ campos ;
180+ foreach ($ arrQuery as $ key ->$ campos ){
181+ if (isset ($ arrQuery [$ key -1 ]) && in_array ($ arrQuery [$ key -1 ], $ arrTables )){
182+ $ table = $ arrQuery [$ key -1 ];
183+ continue ;
184+ }else {
185+
186+ }
187+ if (in_array ($ campos , $ arrTables )){
188+ if ($ campos !=$ table ) $ table = $ campos ;
171189 }else {
172190 if (count ($ bindings )>$ ind ){
173191 array_push ($ new_format [$ table ], ['campo ' => $ campos , 'binding ' => $ ind ]);
@@ -213,7 +231,7 @@ private function compileNewQuery($query, $bindings)
213231 }
214232 }
215233 echo 'Total execution time in seconds: ' . (microtime (true ) - $ time_start ).'<br> ' ;
216- return $ newQuery ;
234+ return $ newQuery ;
217235 }
218236
219237 /**
0 commit comments