@@ -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
@@ -148,12 +148,12 @@ private function compile(Builder $builder)
148
148
}
149
149
150
150
$ cache_tables = env ('SYBASE_CACHE_TABLES ' );
151
- $ cache = !key_exists ('cache_tables ' , $ builder ->connection ->config ) || $ builder ->connection ->config ['cache_tables ' ];
151
+ $ cache = ! key_exists ('cache_tables ' , $ builder ->connection ->config ) || $ builder ->connection ->config ['cache_tables ' ];
152
152
153
153
$ types = [];
154
154
155
155
foreach ($ arrTables as $ tables ) {
156
- preg_match (
156
+ preg_match (
157
157
"/(?:(?'table'.*)(?: as )(?'alias'.*))|(?'tables'.*)/ " ,
158
158
strtolower ($ tables ),
159
159
$ alias
@@ -165,10 +165,11 @@ private function compile(Builder $builder)
165
165
$ tables = $ alias ['table ' ];
166
166
}
167
167
168
- if ($ cache_tables && $ cache ) {
169
- $ aux = Cache::remember ('sybase_columns/ ' .$ tables .'.columns_info ' , env ('SYBASE_CACHE_TABLES_TIME ' ) ?? 3600 , function () use ($ tables ) {
168
+ if ($ cache_tables && $ cache ) {
169
+ $ aux = Cache::remember ('sybase_columns/ ' .$ tables .'.columns_info ' , env ('SYBASE_CACHE_TABLES_TIME ' ) ?? 3600 , function () use ($ tables ) {
170
170
$ queryString = $ this ->queryString ($ tables );
171
171
$ queryRes = $ this ->getPdo ()->query ($ queryString );
172
+
172
173
return $ queryRes ->fetchAll (PDO ::FETCH_NAMED );
173
174
});
174
175
} else {
@@ -191,8 +192,10 @@ private function compile(Builder $builder)
191
192
192
193
$ keys = [];
193
194
194
- $ convert = function ($ column , $ v ) use ($ types ) {
195
- if (is_null ($ v )) return null ;
195
+ $ convert = function ($ column , $ v ) use ($ types ) {
196
+ if (is_null ($ v )) {
197
+ return null ;
198
+ }
196
199
197
200
$ variable_type = $ types [strtolower ($ column )];
198
201
@@ -205,7 +208,7 @@ private function compile(Builder $builder)
205
208
206
209
if (isset ($ builder ->values )) {
207
210
foreach ($ builder ->values as $ key => $ value ) {
208
- if (gettype ($ value ) === 'array ' ) {
211
+ if (gettype ($ value ) === 'array ' ) {
209
212
foreach ($ value as $ k => $ v ) {
210
213
$ keys [] = $ convert ($ k , $ v );
211
214
}
@@ -233,7 +236,9 @@ private function compile(Builder $builder)
233
236
}
234
237
}
235
238
} elseif ($ w ['type ' ] == 'between ' ) {
236
- if (count ($ w ['values ' ]) != 2 ) { return []; }
239
+ if (count ($ w ['values ' ]) != 2 ) {
240
+ return [];
241
+ }
237
242
foreach ($ w ['values ' ] as $ v ) {
238
243
if (gettype ($ v ) !== 'object ' ) {
239
244
$ keys [] = $ convert ($ k , $ v );
@@ -316,7 +321,7 @@ private function queryString($tables)
316
321
*
317
322
* @param string $query
318
323
* @param array $bindings
319
- * @return mixed $newBinds
324
+ * @return mixed $newBinds
320
325
*/
321
326
private function compileBindings ($ query , $ bindings )
322
327
{
@@ -354,17 +359,17 @@ private function compileNewQuery($query, $bindings)
354
359
$ bindings = $ this ->compileBindings ($ query , $ bindings );
355
360
$ partQuery = explode ('? ' , $ query );
356
361
357
- $ bindings = array_map (fn ($ v ) => gettype ($ v ) === 'string ' ? str_replace ('\'' , '\'\'' , $ v ) : $ v , $ bindings );
358
- $ bindings = array_map (fn ($ v ) => gettype ($ v ) === 'string ' ? "' {$ v }' " : $ v , $ bindings );
359
- $ bindings = array_map (fn ($ v ) => gettype ($ v ) === 'NULL ' ? 'NULL ' : $ v , $ bindings );
362
+ $ bindings = array_map (fn ($ v ) => gettype ($ v ) === 'string ' ? str_replace ('\'' , '\'\'' , $ v ) : $ v , $ bindings );
363
+ $ bindings = array_map (fn ($ v ) => gettype ($ v ) === 'string ' ? "' {$ v }' " : $ v , $ bindings );
364
+ $ bindings = array_map (fn ($ v ) => gettype ($ v ) === 'NULL ' ? 'NULL ' : $ v , $ bindings );
360
365
361
- $ newQuery = join (array_map (fn ($ k1 , $ k2 ) => $ k1 .$ k2 , $ partQuery , $ bindings ));
366
+ $ newQuery = join (array_map (fn ($ k1 , $ k2 ) => $ k1 .$ k2 , $ partQuery , $ bindings ));
362
367
$ newQuery = str_replace ('[] ' , '' , $ newQuery );
363
368
364
369
$ db_charset = env ('SYBASE_DATABASE_CHARSET ' );
365
370
$ app_charset = env ('SYBASE_APPLICATION_CHARSET ' );
366
371
367
- if ($ db_charset && $ app_charset ) {
372
+ if ($ db_charset && $ app_charset ) {
368
373
$ newQuery = mb_convert_encoding ($ newQuery , $ db_charset , $ app_charset );
369
374
}
370
375
@@ -402,16 +407,17 @@ public function select($query, $bindings = [], $useReadPdo = true)
402
407
do {
403
408
$ result += $ statement ->fetchAll ($ this ->getFetchMode ());
404
409
} while ($ statement ->nextRowset ());
405
- } catch (\Exception $ e ) {}
410
+ } catch (\Exception $ e ) {
411
+ }
406
412
407
413
$ result = [...$ result ];
408
414
409
415
$ db_charset = env ('SYBASE_DATABASE_CHARSET ' );
410
416
$ app_charset = env ('SYBASE_APPLICATION_CHARSET ' );
411
417
412
- if ($ db_charset && $ app_charset ) {
413
- foreach ($ result as &$ r ) {
414
- foreach ($ r as $ k => &$ v ) {
418
+ if ($ db_charset && $ app_charset ) {
419
+ foreach ($ result as &$ r ) {
420
+ foreach ($ r as $ k => &$ v ) {
415
421
$ v = gettype ($ v ) === 'string ' ? mb_convert_encoding ($ v , $ app_charset , $ db_charset ) : $ v ;
416
422
}
417
423
}
@@ -425,7 +431,7 @@ public function select($query, $bindings = [], $useReadPdo = true)
425
431
* Get the statement.
426
432
*
427
433
* @param string $query
428
- * @param mixed|array $bindings
434
+ * @param mixed|array $bindings
429
435
* @return bool
430
436
*/
431
437
public function statement ($ query , $ bindings = [])
0 commit comments