@@ -20,8 +20,6 @@ class Connection extends IlluminateConnection
20
20
{
21
21
/**
22
22
* All types without quotes in Sybase's query.
23
- *
24
- * @var array
25
23
*/
26
24
private array $ numeric = [
27
25
'int ' , 'numeric ' , 'bigint ' , 'integer ' , 'smallint ' , 'tinyint ' , 'decimal ' , 'double ' , 'float ' , 'real ' , 'bit ' ,
@@ -31,7 +29,6 @@ class Connection extends IlluminateConnection
31
29
/**
32
30
* Execute a Closure within a transaction.
33
31
*
34
- * @param Closure $callback
35
32
* @param int $attempts
36
33
* @return mixed
37
34
*
@@ -54,9 +51,9 @@ public function transaction(Closure $callback, $attempts = 1)
54
51
$ this ->pdo ->exec ('COMMIT TRAN ' );
55
52
}
56
53
57
- // If we catch an exception, we will roll back so nothing gets messed
58
- // up in the database. Then we'll re-throw the exception so it can
59
- // be handled how the developer sees fit for their applications.
54
+ // If we catch an exception, we will roll back so nothing gets messed
55
+ // up in the database. Then we'll re-throw the exception so it can
56
+ // be handled how the developer sees fit for their applications.
60
57
catch (Exception $ e ) {
61
58
$ this ->pdo ->exec ('ROLLBACK TRAN ' );
62
59
@@ -101,7 +98,7 @@ public function select($query, $bindings = [], $useReadPdo = true)
101
98
$ result = [...$ result ];
102
99
103
100
$ application_encoding = config ('database.sybase.application_encoding ' );
104
- if (!$ application_encoding ) {
101
+ if (! $ application_encoding ) {
105
102
return $ result ;
106
103
}
107
104
$ database_charset = config ('database.sybase.database_charset ' );
@@ -129,39 +126,37 @@ public function select($query, $bindings = [], $useReadPdo = true)
129
126
*
130
127
* @link http://stackoverflow.com/questions/2718628/pdoparam-for-type-decimal
131
128
*
132
- * @param string $query
133
- * @param array $bindings
134
129
* @return string $query
130
+ *
135
131
* @throws Exception
136
132
*/
137
133
private function compileNewQuery (string $ query , array $ bindings )
138
134
{
139
135
$ bindings = $ this ->compileBindings ($ query , $ bindings );
140
136
$ partQuery = explode ('? ' , $ query );
141
137
142
- $ bindings = array_map (fn ($ v ) => gettype ($ v ) === 'string ' ? str_replace ('\'' , '\'\'' , $ v ) : $ v , $ bindings );
143
- $ bindings = array_map (fn ($ v ) => gettype ($ v ) === 'string ' ? "' {$ v }' " : $ v , $ bindings );
144
- $ bindings = array_map (fn ($ v ) => gettype ($ v ) === 'NULL ' ? 'NULL ' : $ v , $ bindings );
138
+ $ bindings = array_map (fn ($ v ) => gettype ($ v ) === 'string ' ? str_replace ('\'' , '\'\'' , $ v ) : $ v , $ bindings );
139
+ $ bindings = array_map (fn ($ v ) => gettype ($ v ) === 'string ' ? "' {$ v }' " : $ v , $ bindings );
140
+ $ bindings = array_map (fn ($ v ) => gettype ($ v ) === 'NULL ' ? 'NULL ' : $ v , $ bindings );
145
141
146
- $ newQuery = join (array_map (fn ($ k1 , $ k2 ) => $ k1 .$ k2 , $ partQuery , $ bindings ));
142
+ $ newQuery = implode (array_map (fn ($ k1 , $ k2 ) => $ k1 .$ k2 , $ partQuery , $ bindings ));
147
143
$ newQuery = str_replace ('[] ' , '' , $ newQuery );
148
144
$ application_encoding = config ('database.sybase.application_encoding ' );
149
- if (!$ application_encoding ) {
145
+ if (! $ application_encoding ) {
150
146
return $ newQuery ;
151
147
}
152
148
$ database_charset = config ('database.sybase.database_charset ' );
153
149
$ application_charset = config ('database.sybase.application_charset ' );
154
150
if (is_null ($ database_charset ) || is_null ($ application_charset )) {
155
151
throw new Exception ('[SYBASE] Database Charset and App Charset not set ' );
156
152
}
153
+
157
154
return mb_convert_encoding ($ newQuery , $ database_charset , $ application_charset );
158
155
}
159
156
160
157
/**
161
158
* Set new bindings with specified column types to Sybase.
162
159
*
163
- * @param string $query
164
- * @param array $bindings
165
160
* @return array $newBinds
166
161
*/
167
162
private function compileBindings (string $ query , array $ bindings )
@@ -183,15 +178,14 @@ private function compileBindings(string $query, array $bindings)
183
178
/**
184
179
* Compile the bindings for select/insert/update/delete.
185
180
*
186
- * @param Builder $builder
187
181
* @return array
188
182
*/
189
183
private function compile (Builder $ builder )
190
184
{
191
185
$ arrTables = [];
192
186
193
187
$ arrTables [] = $ builder ->from ;
194
- if (!empty ($ builder ->joins )) {
188
+ if (! empty ($ builder ->joins )) {
195
189
foreach ($ builder ->joins as $ join ) {
196
190
$ arrTables [] = $ join ->table ;
197
191
}
@@ -223,7 +217,7 @@ private function compile(Builder $builder)
223
217
}
224
218
225
219
if ($ cache ) {
226
- $ cacheTime = key_exists ('cache_time ' ,
220
+ $ cacheTime = array_key_exists ('cache_time ' ,
227
221
$ builder ->connection ->config ) ? $ builder ->connection ->config ['cache_time ' ] : 3600 ;
228
222
$ aux = cache ()->remember ("sybase_columns. $ tables.columns_info " , $ cacheTime , function () use ($ tables ) {
229
223
$ queryString = $ this ->queryString ($ tables );
@@ -243,7 +237,7 @@ private function compile(Builder $builder)
243
237
$ types [strtolower ($ row ['name ' ])] = $ row ['type ' ];
244
238
$ types [strtolower ($ tables .'. ' .$ row ['name ' ])] = $ row ['type ' ];
245
239
246
- if (!empty ($ alias ['alias ' ])) {
240
+ if (! empty ($ alias ['alias ' ])) {
247
241
$ types [strtolower ($ alias ['alias ' ].'. ' .$ row ['name ' ])] = $ row ['type ' ];
248
242
}
249
243
}
@@ -312,15 +306,14 @@ private function compile(Builder $builder)
312
306
/**
313
307
* Query string.
314
308
*
315
- * @param string $tables
316
309
* @return string
317
310
*/
318
311
private function queryString (string $ tables )
319
312
{
320
313
$ tables = str_replace ('.. ' , '.dbo. ' , $ tables );
321
314
$ explicitDB = explode ('.dbo. ' , $ tables );
322
315
323
- // Has domain.table
316
+ // Has domain.table
324
317
if (isset ($ explicitDB [1 ])) {
325
318
return <<<SQL
326
319
SELECT
@@ -451,7 +444,6 @@ protected function getDefaultPostProcessor()
451
444
*
452
445
* @param string $query
453
446
* @param array $bindings
454
- * @param Closure $callback
455
447
* @return mixed
456
448
*
457
449
* @throws QueryException
@@ -469,6 +461,7 @@ protected function runQueryCallback($query, $bindings, Closure $callback)
469
461
throw new PDOException ($ finalErrorMessage , (int ) $ errorInfo [1 ]);
470
462
}
471
463
}
464
+
472
465
return $ result ;
473
466
474
467
} catch (Throwable $ e ) {
0 commit comments