-
Notifications
You must be signed in to change notification settings - Fork 214
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allows Doctrine usage on different major versions which change the way queries are executed and fetched.
- Loading branch information
1 parent
022da09
commit 9314825
Showing
12 changed files
with
135 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
namespace FluidTYPO3\Flux\Utility; | ||
|
||
use Doctrine\DBAL\FetchMode; | ||
use Doctrine\DBAL\Result; | ||
use TYPO3\CMS\Core\Database\Query\QueryBuilder; | ||
|
||
class DoctrineQueryProxy | ||
{ | ||
/** | ||
* Returns \Doctrine\DBAL\Result on v11+, \Doctrine\DBAL\Driver\ResultStatement on v10 | ||
* | ||
* @return Result | ||
*/ | ||
public static function executeQueryOnQueryBuilder(QueryBuilder $queryBuilder) | ||
{ | ||
if (method_exists($queryBuilder, 'executeQuery')) { | ||
return $queryBuilder->executeQuery(); | ||
} | ||
/** @var Result $result */ | ||
$result = $queryBuilder->execute(); | ||
return $result; | ||
} | ||
|
||
public static function fetchAssociative(Result $result): ?array | ||
{ | ||
if (method_exists($result, 'fetchAssociative')) { | ||
/** @var array|null $output */ | ||
$output = $result->fetchAssociative() ?: null; | ||
} else { | ||
/** @var array|null $output */ | ||
$output = $result->fetch(FetchMode::ASSOCIATIVE); | ||
} | ||
|
||
return $output; | ||
} | ||
|
||
public static function fetchAllAssociative(Result $result): array | ||
{ | ||
if (method_exists($result, 'fetchAllAssociative')) { | ||
return $result->fetchAllAssociative() ?: []; | ||
} | ||
return $result->fetchAll(FetchMode::ASSOCIATIVE) ?: []; | ||
} | ||
} |
Oops, something went wrong.