@@ -65,9 +65,9 @@ public function transaction(Closure $callback, $attempts = 1)
65
65
$ this ->pdo ->exec ('COMMIT TRAN ' );
66
66
}
67
67
68
- // If we catch an exception, we will roll back so nothing gets messed
69
- // up in the database. Then we'll re-throw the exception so it can
70
- // be handled how the developer sees fit for their applications.
68
+ // If we catch an exception, we will roll back so nothing gets messed
69
+ // up in the database. Then we'll re-throw the exception so it can
70
+ // be handled how the developer sees fit for their applications.
71
71
catch (Exception $ e ) {
72
72
$ this ->pdo ->exec ('ROLLBACK TRAN ' );
73
73
@@ -150,7 +150,7 @@ private function compile(Builder $builder)
150
150
$ cache_columns = env ('SYBASE_CACHE_COLUMNS ' );
151
151
152
152
foreach ($ arrTables as $ tables ) {
153
- preg_match (
153
+ preg_match (
154
154
"/(?:(?'table'.*)(?: as )(?'alias'.*))|(?'tables'.*)/ " ,
155
155
strtolower ($ tables ),
156
156
$ alias
@@ -162,10 +162,11 @@ private function compile(Builder $builder)
162
162
$ tables = $ alias ['table ' ];
163
163
}
164
164
165
- if ($ cache_columns == true ) {
166
- $ aux = Cache::remember ('sybase_columns/ ' .$ tables .'.columns_info ' , env ('SYBASE_CACHE_COLUMNS_TIME ' ) ?? 600 , function () use ($ tables ) {
165
+ if ($ cache_columns == true ) {
166
+ $ aux = Cache::remember ('sybase_columns/ ' .$ tables .'.columns_info ' , env ('SYBASE_CACHE_COLUMNS_TIME ' ) ?? 600 , function () use ($ tables ) {
167
167
$ queryString = $ this ->queryString ($ tables );
168
168
$ queryRes = $ this ->getPdo ()->query ($ queryString );
169
+
169
170
return $ queryRes ->fetchAll (PDO ::FETCH_NAMED );
170
171
});
171
172
} else {
@@ -188,8 +189,10 @@ private function compile(Builder $builder)
188
189
189
190
$ keys = [];
190
191
191
- $ convert = function ($ column , $ v ) use ($ types ) {
192
- if (is_null ($ v )) return null ;
192
+ $ convert = function ($ column , $ v ) use ($ types ) {
193
+ if (is_null ($ v )) {
194
+ return null ;
195
+ }
193
196
194
197
$ variable_type = $ types [strtolower ($ column )];
195
198
@@ -202,7 +205,7 @@ private function compile(Builder $builder)
202
205
203
206
if (isset ($ builder ->values )) {
204
207
foreach ($ builder ->values as $ key => $ value ) {
205
- if (gettype ($ value ) === 'array ' ) {
208
+ if (gettype ($ value ) === 'array ' ) {
206
209
foreach ($ value as $ k => $ v ) {
207
210
$ keys [] = $ convert ($ k , $ v );
208
211
}
@@ -230,7 +233,9 @@ private function compile(Builder $builder)
230
233
}
231
234
}
232
235
} elseif ($ w ['type ' ] == 'between ' ) {
233
- if (count ($ w ['values ' ]) != 2 ) { return []; }
236
+ if (count ($ w ['values ' ]) != 2 ) {
237
+ return [];
238
+ }
234
239
foreach ($ w ['values ' ] as $ v ) {
235
240
if (gettype ($ v ) !== 'object ' ) {
236
241
$ keys [] = $ convert ($ k , $ v );
@@ -312,7 +317,7 @@ private function queryString($tables)
312
317
*
313
318
* @param string $query
314
319
* @param array $bindings
315
- * @return mixed $newBinds
320
+ * @return mixed $newBinds
316
321
*/
317
322
private function compileBindings ($ query , $ bindings )
318
323
{
@@ -350,16 +355,16 @@ private function compileNewQuery($query, $bindings)
350
355
$ bindings = $ this ->compileBindings ($ query , $ bindings );
351
356
$ partQuery = explode ('? ' , $ query );
352
357
353
- $ bindings = array_map (fn ($ v ) => gettype ($ v ) === 'string ' ? str_replace ('\'' , '\'\'' , $ v ) : $ v , $ bindings );
354
- $ bindings = array_map (fn ($ v ) => gettype ($ v ) === 'string ' ? "' {$ v }' " : $ v , $ bindings );
358
+ $ bindings = array_map (fn ($ v ) => gettype ($ v ) === 'string ' ? str_replace ('\'' , '\'\'' , $ v ) : $ v , $ bindings );
359
+ $ bindings = array_map (fn ($ v ) => gettype ($ v ) === 'string ' ? "' {$ v }' " : $ v , $ bindings );
355
360
356
- $ newQuery = join (array_map (fn ($ k1 , $ k2 ) => $ k1 .$ k2 , $ partQuery , $ bindings ));
361
+ $ newQuery = join (array_map (fn ($ k1 , $ k2 ) => $ k1 .$ k2 , $ partQuery , $ bindings ));
357
362
$ newQuery = str_replace ('[] ' , '' , $ newQuery );
358
363
359
364
$ db_charset = env ('DB_CHARSET ' );
360
365
$ app_charset = env ('APPLICATION_CHARSET ' );
361
366
362
- if ($ db_charset && $ app_charset ) {
367
+ if ($ db_charset && $ app_charset ) {
363
368
$ newQuery = mb_convert_encoding ($ newQuery , $ db_charset , $ app_charset );
364
369
}
365
370
@@ -389,15 +394,14 @@ public function select($query, $bindings = [], $useReadPdo = true)
389
394
$ bindings
390
395
));
391
396
392
-
393
397
$ result = $ statement ->fetchAll ($ this ->getFetchMode ());
394
398
395
399
$ db_charset = env ('DB_CHARSET ' );
396
400
$ app_charset = env ('APPLICATION_CHARSET ' );
397
401
398
- if ($ db_charset && $ app_charset ) {
399
- foreach ($ result as &$ r ) {
400
- foreach ($ r as $ k => &$ v ) {
402
+ if ($ db_charset && $ app_charset ) {
403
+ foreach ($ result as &$ r ) {
404
+ foreach ($ r as $ k => &$ v ) {
401
405
$ v = gettype ($ v ) === 'string ' ? mb_convert_encoding ($ v , $ app_charset , $ db_charset ) : $ v ;
402
406
}
403
407
}
@@ -411,7 +415,7 @@ public function select($query, $bindings = [], $useReadPdo = true)
411
415
* Get the statement.
412
416
*
413
417
* @param string $query
414
- * @param mixed|array $bindings
418
+ * @param mixed|array $bindings
415
419
* @return bool
416
420
*/
417
421
public function statement ($ query , $ bindings = [])
0 commit comments