-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
no issue - progressively decouple bridge in order to hide it as an im…
…plementation detail
- Loading branch information
Showing
45 changed files
with
317 additions
and
269 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -117,6 +117,7 @@ Setting it up is easier than standalone setup: | |
```php | ||
use Doctrine\DBAL\DriverManager; | ||
use MakinaCorpus\QueryBuilder\Bridge\Doctrine\DoctrineQueryBuilder; | ||
use MakinaCorpus\QueryBuilder\DatabaseSession; | ||
|
||
// Create or fetch your doctrine/dbal connection. | ||
$connection = DriverManager::getConnection([ | ||
|
@@ -125,9 +126,19 @@ $connection = DriverManager::getConnection([ | |
]); | ||
|
||
// Create the query builder. | ||
$queryBuilder = new DoctrineQueryBuilder($connection); | ||
$session = new DoctrineQueryBuilder($connection); | ||
\assert($session instanceof DatabaseSession); | ||
``` | ||
|
||
:::warning | ||
For the final user, the *bridge* should be hidden and the | ||
`MakinaCorpus\QueryBuilder\DatabaseSession` exposed instead. The bridge is an | ||
internal component that ties the query builder with a third-party driver. | ||
|
||
All useful features are exposed via the `DatabaseSession` whereas the bridge | ||
should remain hidden, as its signature is subject to changes. | ||
::: | ||
|
||
:::tip | ||
You don't need to specify the SQL dialect to use, it will be derived from | ||
the `doctrine/dbal` connection automatically, without requiring any extra SQL | ||
|
@@ -139,7 +150,7 @@ query to do so. | |
Now we can write a query and execute it directly: | ||
|
||
```php | ||
$result = $queryBuilder | ||
$result = $session | ||
->select('users') | ||
->column('*') | ||
->where('id', '[email protected]') | ||
|
@@ -179,14 +190,25 @@ Setting it up is easier than standalone setup: | |
|
||
```php | ||
use MakinaCorpus\QueryBuilder\Bridge\Pdo\PdoQueryBuilder; | ||
use MakinaCorpus\QueryBuilder\DatabaseSession; | ||
|
||
// Create or fetch your PDO connection. | ||
$connection = new \PDO('pgsql:...'); | ||
|
||
// User facade for you to build SQL queries. | ||
$queryBuilder = new PdoQueryBuilder($connection); | ||
$session = new PdoQueryBuilder($connection); | ||
\assert($session instanceof DatabaseSession); | ||
``` | ||
|
||
:::warning | ||
For the final user, the *bridge* should be hidden and the | ||
`MakinaCorpus\QueryBuilder\DatabaseSession` exposed instead. The bridge is an | ||
internal component that ties the query builder with a third-party driver. | ||
|
||
All useful features are exposed via the `DatabaseSession` whereas the bridge | ||
should remain hidden, as its signature is subject to changes. | ||
::: | ||
|
||
:::tip | ||
You don't need to specify the SQL dialect to use, it will be derived from | ||
the `PDO` connection automatically. | ||
|
@@ -195,7 +217,7 @@ the `PDO` connection automatically. | |
### 3. Write your query and execute it | ||
|
||
```php | ||
$result = $queryBuilder | ||
$result = $session | ||
->select('users') | ||
->column('*') | ||
->where('id', '[email protected]') | ||
|
@@ -258,7 +280,6 @@ declare (strict_types=1); | |
|
||
namespace App\Controller; | ||
|
||
use MakinaCorpus\QueryBuilder\Bridge\Doctrine\DoctrineQueryBuilder; | ||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | ||
use Symfony\Component\HttpFoundation\Response; | ||
use Symfony\Component\Routing\Annotation\Route; | ||
|
@@ -267,9 +288,9 @@ class TestingController extends AbstractController | |
{ | ||
#[Route('/testing/query-builder', name: 'testing_query_builder')] | ||
public function testQueryBuilder( | ||
DoctrineQueryBuilder $queryBuilder, | ||
DatabaseSession $session, | ||
): Response { | ||
$result = $queryBuilder | ||
$result = $session | ||
->select('some_table') | ||
->executeQuery() | ||
; | ||
|
@@ -295,10 +316,10 @@ If you need to use another connection, please read the next chapter. | |
### Using a query builder for another connection | ||
|
||
You may have configured more than one `doctrine/dbal` connection, this bundle | ||
will register as many `MakinaCorpus\QueryBuilder\Bridge\Doctrine\DoctrineQueryBuilder` | ||
services as doctrine connections being configured. | ||
will register as many `MakinaCorpus\QueryBuilder\DatabaseSession` services as | ||
doctrine connections being configured. | ||
|
||
Each service identifier is `query_builder.doctrine.CONNECTION_NAME` where | ||
Each service identifier is `query_builder.session.CONNECTION_NAME` where | ||
`CONNECTION_NAME` is the Doctrine bundle configured connection identifier. | ||
|
||
:::tip | ||
|
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
Oops, something went wrong.