Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no issue - introduce the BridgeFactory #23

Merged
merged 2 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

## Next

* [feature] ⭐️ Add `MakinaCorpus\QueryBuilder\BridgeFactory` for creating
standalone connections.
* [fix] Better version compare algorithm, with less erroneous edge cases.
* [deprecation] ⚠️ Renamed `MakinaCorpus\QueryBuilder\Bridge\Doctrine\DoctrineQueryBuilder`
to `MakinaCorpus\QueryBuilder\Bridge\Doctrine\DoctrineBridge`.
* [deprecation] ⚠️ Renamed `MakinaCorpus\QueryBuilder\Bridge\Pdo\PdoQueryBuilder`
to `MakinaCorpus\QueryBuilder\Bridge\Pdo\PdoBridge`.

## 1.5.5

* [fix] Handle `mysqli` in `Dsn` class.
Expand Down
4 changes: 2 additions & 2 deletions docs/content/bridges/error.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ call the `Bridge::disableErrorConverter()` method when initializing the bridge:

```php
use Doctrine\DBAL\DriverManager;
use MakinaCorpus\QueryBuilder\Bridge\Doctrine\DoctrineQueryBuilder;
use MakinaCorpus\QueryBuilder\Bridge\Doctrine\DoctrineBridge;

$connection = DriverManager::getConnection(['driver' => 'pdo_pgsql', /* ... */]);
$bridge = new DoctrineQueryBuilder($connection);
$bridge = new DoctrineBridge($connection);

// Here it is:
$bridge->disableErrorConverter();
Expand Down
8 changes: 4 additions & 4 deletions docs/content/introduction/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ Setting it up is easier than standalone setup:

```php
use Doctrine\DBAL\DriverManager;
use MakinaCorpus\QueryBuilder\Bridge\Doctrine\DoctrineQueryBuilder;
use MakinaCorpus\QueryBuilder\Bridge\Doctrine\DoctrineBridge;
use MakinaCorpus\QueryBuilder\DatabaseSession;

// Create or fetch your doctrine/dbal connection.
Expand All @@ -126,7 +126,7 @@ $connection = DriverManager::getConnection([
]);

// Create the query builder.
$session = new DoctrineQueryBuilder($connection);
$session = new DoctrineBridge($connection);
\assert($session instanceof DatabaseSession);
```

Expand Down Expand Up @@ -189,14 +189,14 @@ composer require makinacorpus/query-builder
Setting it up is easier than standalone setup:

```php
use MakinaCorpus\QueryBuilder\Bridge\Pdo\PdoQueryBuilder;
use MakinaCorpus\QueryBuilder\Bridge\Pdo\PdoBridge;
use MakinaCorpus\QueryBuilder\DatabaseSession;

// Create or fetch your PDO connection.
$connection = new \PDO('pgsql:...');

// User facade for you to build SQL queries.
$session = new PdoQueryBuilder($connection);
$session = new PdoBridge($connection);
\assert($session instanceof DatabaseSession);
```

Expand Down
12 changes: 6 additions & 6 deletions docs/content/query/result.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ you can call `Query::executeQuery()` over your queries, for example:

```php
use Doctrine\DBAL\DriverManager;
use MakinaCorpus\QueryBuilder\Bridge\Doctrine\DoctrineQueryBuilder;
use MakinaCorpus\QueryBuilder\Bridge\Doctrine\DoctrineBridge;

$session = new DoctrineQueryBuilder(
$session = new DoctrineBridge(
DriverManager::getConnection([
'driver' => 'pdo_pgsql',
// ... driver options.
Expand All @@ -46,9 +46,9 @@ You may also directly execute raw SQL code as such:

```php
use Doctrine\DBAL\DriverManager;
use MakinaCorpus\QueryBuilder\Bridge\Doctrine\DoctrineQueryBuilder;
use MakinaCorpus\QueryBuilder\Bridge\Doctrine\DoctrineBridge;

$session = new DoctrineQueryBuilder(
$session = new DoctrineBridge(
DriverManager::getConnection([
'driver' => 'pdo_pgsql',
// ... driver options.
Expand Down Expand Up @@ -79,10 +79,10 @@ instances:

```php
use Doctrine\DBAL\DriverManager;
use MakinaCorpus\QueryBuilder\Bridge\Doctrine\DoctrineQueryBuilder;
use MakinaCorpus\QueryBuilder\Bridge\Doctrine\DoctrineBridge;
use MakinaCorpus\QueryBuilder\Result\ResultRow;

$session = new DoctrineQueryBuilder(
$session = new DoctrineBridge(
DriverManager::getConnection([
'driver' => 'pdo_pgsql',
// ... driver options.
Expand Down
9 changes: 9 additions & 0 deletions src/Bridge/Doctrine/DoctrineBridge.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

declare(strict_types=1);

namespace MakinaCorpus\QueryBuilder\Bridge\Doctrine;

class DoctrineBridge extends DoctrineQueryBuilder
{
}
8 changes: 8 additions & 0 deletions src/Bridge/Doctrine/DoctrineQueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
use MakinaCorpus\QueryBuilder\Vendor;
use MakinaCorpus\QueryBuilder\Writer\Writer;

/**
* @deprecated This will be removed in 2.0, use DoctrineBridge instead.
* @see DoctrineBridge
*/
class DoctrineQueryBuilder extends AbstractBridge
{
private Connection $connection;
Expand All @@ -28,6 +32,10 @@ public function __construct(
parent::__construct();

$this->connection = $connection;

if (static::class === self::class) {
@\trigger_error(\sprintf("Class '%s' is deprecated and will be removed in 2.0, use '%s' instead.", DoctrineQueryBuilder::class, DoctrineBridge::class));
}
}

/**
Expand Down
9 changes: 9 additions & 0 deletions src/Bridge/Pdo/PdoBridge.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

declare(strict_types=1);

namespace MakinaCorpus\QueryBuilder\Bridge\Pdo;

class PdoBridge extends PdoQueryBuilder
{
}
8 changes: 8 additions & 0 deletions src/Bridge/Pdo/PdoQueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
use MakinaCorpus\QueryBuilder\Result\Result;
use MakinaCorpus\QueryBuilder\Vendor;

/**
* @deprecated This will be removed in 2.0, use PdoBridge instead.
* @see PdoBridge
*/
class PdoQueryBuilder extends AbstractBridge
{
private ?\PDO $connection = null;
Expand All @@ -30,6 +34,10 @@ public function __construct(
parent::__construct();

$this->connection = $connection;

if (static::class === self::class) {
@\trigger_error(\sprintf("Class '%s' is deprecated and will be removed in 2.0, use '%s' instead.", PdoQueryBuilder::class, PdoBridge::class));
}
}

/**
Expand Down
Loading
Loading