@@ -117,7 +117,11 @@ private function compileForSelect(Builder $builder, $bindings) {
117117 }
118118 $ newFormat = [];
119119 foreach ($ arrTables as $ tables ) {
120- preg_match ("/(?:(?'table'.*)(?: as )(?'alias'.*))|(?'tables'.*)/ " , $ tables , $ alias );
120+ preg_match (
121+ "/(?:(?'table'.*)(?: as )(?'alias'.*))|(?'tables'.*)/ " ,
122+ $ tables ,
123+ $ alias
124+ );
121125 if (empty ($ alias ['alias ' ])) {
122126 $ tables = $ alias ['tables ' ];
123127 } else {
@@ -132,7 +136,9 @@ private function compileForSelect(Builder $builder, $bindings) {
132136 $ tipos [strtolower ($ tables . '. ' . $ row ['name ' ])] = $ row ['type ' ];
133137
134138 if (!empty ($ alias ['alias ' ])) {
135- $ tipos [strtolower ($ alias ['alias ' ] . '. ' . $ row ['name ' ])] = $ row ['type ' ];
139+ $ tipos [
140+ strtolower ($ alias ['alias ' ] . '. ' . $ row ['name ' ])
141+ ] = $ row ['type ' ];
136142 }
137143 }
138144
@@ -153,9 +159,19 @@ private function compileForSelect(Builder $builder, $bindings) {
153159 $ wheresCount = count ($ wheres );
154160
155161 for ($ ind = 0 ; $ ind < $ wheresCount ; $ ind ++) {
156- if (isset ($ wheres [$ ind ]['value ' ]) && isset ($ tipos [strtolower ($ wheres [$ ind ]['column ' ])])) {
162+ if (
163+ isset ($ wheres [$ ind ]['value ' ]) &&
164+ isset ($ tipos [strtolower ($ wheres [$ ind ]['column ' ])])
165+ ) {
157166 if (is_object ($ wheres [$ ind ]['value ' ]) === false ) {
158- if (in_array (strtolower ($ tipos [strtolower ($ wheres [$ ind ]['column ' ])]), $ this ->withoutQuotes )) {
167+ if (
168+ in_array (
169+ strtolower ($ tipos [
170+ strtolower ($ wheres [$ ind ]['column ' ])
171+ ]),
172+ $ this ->withoutQuotes
173+ )
174+ ) {
159175 if (!is_null ($ bindings [$ i ])) {
160176 $ newBinds [$ i ] = $ bindings [$ i ] / 1 ;
161177 } else {
@@ -179,7 +195,14 @@ private function compileForSelect(Builder $builder, $bindings) {
179195 for ($ ind = 0 ; $ ind < $ wheresCount ; $ ind ++) {
180196 if (isset ($ wheres [$ ind ]['value ' ])) {
181197 if (is_object ($ wheres [$ ind ]['value ' ]) === false ) {
182- if (in_array (strtolower ($ tipos [strtolower ($ wheres [$ ind ]['column ' ])]), $ this ->withoutQuotes )) {
198+ if (
199+ in_array (
200+ strtolower ($ tipos [
201+ strtolower ($ wheres [$ ind ]['column ' ])
202+ ]),
203+ $ this ->withoutQuotes
204+ )
205+ ) {
183206 if (!is_null ($ bindings [$ i ])) {
184207 $ newBinds [$ i ] = $ bindings [$ i ] / 1 ;
185208 } else {
@@ -277,20 +300,35 @@ private function compileBindings($query, $bindings)
277300 return $ bindings ;
278301 }
279302 case "insert " :
280- preg_match ("/(?'tables'.*) \((?'attributes'.*)\) values/i " , $ query , $ matches );
303+ preg_match (
304+ "/(?'tables'.*) \((?'attributes'.*)\) values/i " ,
305+ $ query ,
306+ $ matches
307+ );
281308 break ;
282309 case "update " :
283- preg_match ("/(?'tables'.*) set (?'attributes'.*)/i " , $ query , $ matches );
310+ preg_match (
311+ "/(?'tables'.*) set (?'attributes'.*)/i " ,
312+ $ query ,
313+ $ matches
314+ );
284315 break ;
285316 case "delete " :
286- preg_match ("/(?'tables'.*) where (?'attributes'.*)/i " , $ query , $ matches );
317+ preg_match (
318+ "/(?'tables'.*) where (?'attributes'.*)/i " ,
319+ $ query ,
320+ $ matches
321+ );
287322 break ;
288323 default :
289324 return $ bindings ;
290325 break ;
291326 }
292327
293- $ desQuery = array_intersect_key ($ matches , array_flip (array_filter (array_keys ($ matches ), 'is_string ' )));
328+ $ desQuery = array_intersect_key (
329+ $ matches ,
330+ array_flip (array_filter (array_keys ($ matches ), 'is_string ' ))
331+ );
294332
295333 if (is_array ($ desQuery ['tables ' ])) {
296334 $ desQuery ['tables ' ] = implode ($ desQuery ['tables ' ], ' ' );
@@ -302,7 +340,11 @@ private function compileBindings($query, $bindings)
302340 unset($ matches );
303341 unset($ queryType );
304342 preg_match_all ("/\[([^\]]*)\]/ " , $ desQuery ['attributes ' ], $ arrQuery );
305- preg_match_all ("/\[([^\]]*)\]/ " , str_replace ("].[].[ " , '.. ' , $ desQuery ['tables ' ]), $ arrTables );
343+ preg_match_all (
344+ "/\[([^\]]*)\]/ " ,
345+ str_replace ("].[].[ " , '.. ' , $ desQuery ['tables ' ]),
346+ $ arrTables
347+ );
306348
307349 $ arrQuery = $ arrQuery [1 ];
308350 $ arrTables = $ arrTables [1 ];
@@ -323,10 +365,14 @@ private function compileBindings($query, $bindings)
323365 $ table = $ campos ;
324366 }
325367 if (!array_key_exists ($ table , $ newFormat )) {
326- $ queryRes = $ this ->getPdo ()->query ($ this ->queryStringForCompileBindings ($ table ));
368+ $ queryRes = $ this ->getPdo ()->query (
369+ $ this ->queryStringForCompileBindings ($ table )
370+ );
327371 $ types [$ table ] = $ queryRes ->fetchAll (\PDO ::FETCH_ASSOC );
328372 for ($ k = 0 ; $ k < count ($ types [$ table ]); $ k ++) {
329- $ types [$ table ][$ types [$ table ][$ k ]['name ' ]] = $ types [$ table ][$ k ];
373+ $ types [$ table ][
374+ $ types [$ table ][$ k ]['name ' ]
375+ ] = $ types [$ table ][$ k ];
330376 unset($ types [$ table ][$ k ]);
331377 }
332378 $ newFormat [$ table ] = [];
@@ -335,8 +381,18 @@ private function compileBindings($query, $bindings)
335381
336382 if (!$ itsTable ) {
337383 if (count ($ bindings ) > $ ind ) {
338- array_push ($ newFormat [$ table ], ['campo ' => $ campos , 'binding ' => $ ind ]);
339- if (in_array (strtolower ($ types [$ table ][$ campos ]['type ' ]), $ this ->withoutQuotes )) {
384+ array_push (
385+ $ newFormat [$ table ], [
386+ 'campo ' => $ campos ,
387+ 'binding ' => $ ind
388+ ]
389+ );
390+ if (
391+ in_array (
392+ strtolower ($ types [$ table ][$ campos ]['type ' ]),
393+ $ this ->withoutQuotes
394+ )
395+ ) {
340396 if (!is_null ($ bindings [$ ind ])) {
341397 $ newBinds [$ ind ] = $ bindings [$ ind ] / 1 ;
342398 } else {
@@ -413,9 +469,11 @@ private function queryStringForCompileBindings($table)
413469
414470 /**
415471 * Set new bindings with specified column types to Sybase.
416- * Poderia compilar novamente dos bindings usando os PDO::PARAM, porém, não tem nenhuma constante que lide
417- * com decimais, logo, a única maneira seria colocando PDO::PARAM_STR, que colocaria plicas.
418- * Detalhes: http://stackoverflow.com/questions/2718628/pdoparam-for-type-decimal
472+ * Poderia compilar novamente dos bindings usando os PDO::PARAM, porém,
473+ * não tem nenhuma constante que lide com decimais, logo, a única maneira
474+ * seria colocando PDO::PARAM_STR, que colocaria plicas.
475+ * Detalhes:
476+ * http://stackoverflow.com/questions/2718628/pdoparam-for-type-decimal
419477 *
420478 * @param string $query
421479 * @param array $bindings
@@ -453,22 +511,33 @@ public function compileOffset($offset, $query, $bindings = array(), $me)
453511 $ limit = 999999999999999999999999999 ;
454512 }
455513 $ queryString = $ this ->queryStringForIdentity ($ from );
456- $ identity = $ this ->getPdo ()->query ($ queryString )->fetchAll ($ me ->getFetchMode ())[0 ];
514+ $ identity = $ this ->getPdo ()->query ($ queryString )->fetchAll (
515+ $ me ->getFetchMode ()
516+ )[0 ];
457517
458518 if (count ($ identity ) === 0 ) {
459519 $ queryString = $ this ->queryStringForPrimaries ($ from );
460- $ primaries = $ this ->getPdo ()->query ($ queryString )->fetchAll ($ me ->getFetchMode ());
520+ $ primaries = $ this ->getPdo ()->query ($ queryString )->fetchAll (
521+ $ me ->getFetchMode ()
522+ );
461523 foreach ($ primaries as $ primary ) {
462- $ newArr [] = $ primary ->primary_key . '+0 AS ' . $ primary ->primary_key ;
463- $ whereArr [] = "#tmpPaginate. " . $ primary ->primary_key . ' = #tmpTable. ' . $ primary ->primary_key ;
524+ $ newArr [] = $ primary ->primary_key . '+0 AS ' .
525+ $ primary ->primary_key ;
526+ $ whereArr [] = "#tmpPaginate. " . $ primary ->primary_key .
527+ ' = #tmpTable. ' . $ primary ->primary_key ;
464528 }
465529 $ resPrimaries = implode (', ' , $ newArr );
466530 $ wherePrimaries = implode (' AND ' , $ whereArr );
467531 } else {
468532 $ resPrimaries = $ identity ->column . '+0 AS ' . $ identity ->column ;
469- $ wherePrimaries = "#tmpPaginate. " . $ identity ->column . ' = #tmpTable. ' . $ identity ->column ;
533+ $ wherePrimaries = "#tmpPaginate. " . $ identity ->column .
534+ ' = #tmpTable. ' . $ identity ->column ;
470535 // Offset operation
471- $ this ->getPdo ()->query (str_replace (" from " , " into #tmpPaginate from " , $ this ->compileNewQuery ($ query , $ bindings )));
536+ $ this ->getPdo ()->query (str_replace (
537+ " from " ,
538+ " into #tmpPaginate from " ,
539+ $ this ->compileNewQuery ($ query , $ bindings )
540+ ));
472541 $ this ->getPdo ()->query ("
473542 SELECT
474543 " . $ resPrimaries . ",
@@ -569,7 +638,10 @@ private function queryStringForPrimaries($from)
569638 */
570639 public function select ($ query , $ bindings = array (), $ useReadPdo = true )
571640 {
572- return $ this ->run ($ query , $ bindings , function ($ query , $ bindings ) use ($ useReadPdo ) {
641+ return $ this ->run ($ query , $ bindings , function (
642+ $ query ,
643+ $ bindings
644+ ) use ($ useReadPdo ) {
573645 if ($ this ->pretending ()) {
574646 return [];
575647 }
@@ -584,7 +656,10 @@ public function select($query, $bindings = array(), $useReadPdo = true)
584656 return $ this ->compileOffset ($ offset , $ query , $ bindings , $ this );
585657 } else {
586658 $ result = [];
587- $ statement = $ this ->getPdo ()->query ($ this ->compileNewQuery ($ query , $ bindings ));
659+ $ statement = $ this ->getPdo ()->query ($ this ->compileNewQuery (
660+ $ query ,
661+ $ bindings
662+ ));
588663 do {
589664 $ result += $ statement ->fetchAll ($ this ->getFetchMode ());
590665 } while ($ statement ->nextRowset ());
@@ -604,7 +679,10 @@ public function statement($query, $bindings = array())
604679 if ($ this ->pretending ()) {
605680 return true ;
606681 }
607- return $ this ->getPdo ()->query ($ this ->compileNewQuery ($ query , $ bindings ));
682+ return $ this ->getPdo ()->query ($ this ->compileNewQuery (
683+ $ query ,
684+ $ bindings
685+ ));
608686 });
609687 }
610688
@@ -614,7 +692,10 @@ public function affectingStatement($query, $bindings = [])
614692 if ($ this ->pretending ()) {
615693 return 0 ;
616694 }
617- return $ this ->getPdo ()->query ($ this ->compileNewQuery ($ query , $ bindings ))->rowCount ();
695+ return $ this ->getPdo ()->query ($ this ->compileNewQuery (
696+ $ query ,
697+ $ bindings
698+ ))->rowCount ();
618699 });
619700 }
620701
0 commit comments