Skip to content

Commit 9823017

Browse files
committed
Fixed StyleCI/PHPStan errors
1 parent dcc351d commit 9823017

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

src/QueryDataTable.php

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,11 +1026,12 @@ protected function applyScoutSearch(string $search_keyword): bool
10261026
* @param string $keyName
10271027
* @param array $orderedKeys
10281028
* @return void
1029+
*
10291030
* @throws \Exception If the database driver is unsupported.
10301031
*/
10311032
protected function applyFixedOrderingToQuery(string $keyName, array $orderedKeys)
10321033
{
1033-
$connection = $this->query->getConnection();
1034+
$connection = $this->getConnection();
10341035
$driver_name = $connection->getDriverName();
10351036

10361037
// Escape keyName and orderedKeys
@@ -1040,36 +1041,35 @@ protected function applyFixedOrderingToQuery(string $keyName, array $orderedKeys
10401041
return $connection->escape($value);
10411042
});
10421043

1043-
switch ($driver_name)
1044-
{
1044+
switch ($driver_name) {
10451045
case 'mysql':
10461046
// MySQL
1047-
$this->query->orderByRaw("FIELD($keyName, " . $orderedKeys->implode(',') . ")");
1048-
break;
1049-
1050-
/*
1051-
TODO: test implementations, fix if necessary and uncomment
1052-
case 'pgsql':
1053-
// PostgreSQL
1054-
$this->query->orderByRaw("array_position(ARRAY[" . $orderedKeys->implode(',') . "], $keyName)");
1047+
$this->query->orderByRaw("FIELD($keyName, ".$orderedKeys->implode(',').')');
10551048
break;
10561049

1057-
case 'sqlite':
1058-
case 'sqlsrv':
1059-
// SQLite & Microsoft SQL Server
1060-
1061-
// should be generally compatible with all drivers using SQL syntax (but ugly solution)
1062-
$this->query->orderByRaw(
1063-
"CASE $keyName "
1064-
.
1065-
$orderedKeys
1066-
->map(fn($value, $index) => "WHEN $keyName = $value THEN $index")
1067-
->implode(' ')
1068-
.
1069-
" END"
1070-
);
1071-
break;
1072-
*/
1050+
/*
1051+
TODO: test implementations, fix if necessary and uncomment
1052+
case 'pgsql':
1053+
// PostgreSQL
1054+
$this->query->orderByRaw("array_position(ARRAY[" . $orderedKeys->implode(',') . "], $keyName)");
1055+
break;
1056+
1057+
case 'sqlite':
1058+
case 'sqlsrv':
1059+
// SQLite & Microsoft SQL Server
1060+
1061+
// should be generally compatible with all drivers using SQL syntax (but ugly solution)
1062+
$this->query->orderByRaw(
1063+
"CASE $keyName "
1064+
.
1065+
$orderedKeys
1066+
->map(fn($value, $index) => "WHEN $keyName = $value THEN $index")
1067+
->implode(' ')
1068+
.
1069+
" END"
1070+
);
1071+
break;
1072+
*/
10731073

10741074
default:
10751075
throw new \Exception("Unsupported database driver: $driver_name");

0 commit comments

Comments
 (0)