Skip to content

Commit c640bb3

Browse files
Better naming classes with PDO - part 1. (#258)
1 parent 8a002bd commit c640bb3

7 files changed

Lines changed: 18 additions & 17 deletions

File tree

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* Implements a database command that can be executed against a PDO (PHP Data Object) database connection for MSSQL
1717
* Server.
1818
*/
19-
final class CommandPDO extends AbstractCommandPDO
19+
final class Command extends AbstractCommandPDO
2020
{
2121
public function showDatabases(): array
2222
{
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*
1919
* @link https://www.php.net/manual/en/ref.pdo-sqlsrv.php
2020
*/
21-
final class ConnectionPDO extends AbstractConnectionPDO
21+
final class Connection extends AbstractConnectionPDO
2222
{
2323
public function createBatchQueryResult(QueryInterface $query, bool $each = false): BatchQueryResultInterface
2424
{
@@ -27,7 +27,7 @@ public function createBatchQueryResult(QueryInterface $query, bool $each = false
2727

2828
public function createCommand(string $sql = null, array $params = []): CommandPDOInterface
2929
{
30-
$command = new CommandPDO($this);
30+
$command = new Command($this);
3131

3232
if ($sql !== null) {
3333
$command->setSql($sql);
@@ -46,7 +46,7 @@ public function createCommand(string $sql = null, array $params = []): CommandPD
4646

4747
public function createTransaction(): TransactionInterface
4848
{
49-
return new TransactionPDO($this);
49+
return new Transaction($this);
5050
}
5151

5252
public function getQueryBuilder(): QueryBuilderInterface

src/PDODriver.php renamed to src/Driver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
*
1313
* @link https://www.php.net/manual/en/ref.pdo-sqlsrv.php
1414
*/
15-
final class PDODriver extends AbstractPDODriver
15+
final class Driver extends AbstractPDODriver
1616
{
1717
public function createConnection(): PDO
1818
{

src/Dsn.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ public function __construct(
3131
*
3232
* ```php
3333
* $dsn = new Dsn('sqlsrv', 'localhost', 'yiitest', '1433');
34-
* $db = new ConnectionPDO(new PDODriver($dsn->asString(), 'username', 'password'), $queryCache, $schemaCache);
34+
* $driver = new Driver($dsn->asString(), 'username', 'password');
35+
* $db = new Connection($driver, $schemaCache);
3536
* ```
3637
*
3738
* Will result in the DSN string `sqlsrv:Server=localhost,1433;Database=yiitest`.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
/**
1313
* Implements the MSSQL Server specific transaction.
1414
*/
15-
final class TransactionPDO extends AbstractTransactionPDO
15+
final class Transaction extends AbstractTransactionPDO
1616
{
1717
/**
1818
* Creates a new savepoint.

tests/CommandTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
use Yiisoft\Db\Exception\InvalidConfigException;
1313
use Yiisoft\Db\Exception\NotSupportedException;
1414
use Yiisoft\Db\Expression\Expression;
15-
use Yiisoft\Db\Mssql\ConnectionPDO;
15+
use Yiisoft\Db\Mssql\Connection;
1616
use Yiisoft\Db\Mssql\Dsn;
17-
use Yiisoft\Db\Mssql\PDODriver;
17+
use Yiisoft\Db\Mssql\Driver;
1818
use Yiisoft\Db\Mssql\Tests\Support\TestTrait;
1919
use Yiisoft\Db\Query\Query;
2020
use Yiisoft\Db\Tests\Common\CommonCommandTest;
@@ -359,8 +359,8 @@ public function testDropDefaultValueSql(): void
359359
public function testShowDatabases(): void
360360
{
361361
$dsn = new Dsn('sqlsrv', 'localhost');
362-
$db = new ConnectionPDO(
363-
new PDODriver($dsn->asString(), 'SA', 'YourStrong!Passw0rd'),
362+
$db = new Connection(
363+
new Driver($dsn->asString(), 'SA', 'YourStrong!Passw0rd'),
364364
DbHelper::getSchemaCache(),
365365
);
366366

tests/Support/TestTrait.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
use Yiisoft\Db\Driver\PDO\ConnectionPDOInterface;
88
use Yiisoft\Db\Exception\Exception;
99
use Yiisoft\Db\Exception\InvalidConfigException;
10-
use Yiisoft\Db\Mssql\ConnectionPDO;
10+
use Yiisoft\Db\Mssql\Connection;
1111
use Yiisoft\Db\Mssql\Dsn;
12-
use Yiisoft\Db\Mssql\PDODriver;
12+
use Yiisoft\Db\Mssql\Driver;
1313
use Yiisoft\Db\Tests\Support\DbHelper;
1414

1515
trait TestTrait
@@ -23,8 +23,8 @@ trait TestTrait
2323
*/
2424
protected function getConnection(bool $fixture = false): ConnectionPDOInterface
2525
{
26-
$db = new ConnectionPDO(
27-
new PDODriver($this->getDsn(), 'SA', 'YourStrong!Passw0rd'),
26+
$db = new Connection(
27+
new Driver($this->getDsn(), 'SA', 'YourStrong!Passw0rd'),
2828
DbHelper::getSchemaCache()
2929
);
3030

@@ -39,8 +39,8 @@ protected static function getDb(): ConnectionPDOInterface
3939
{
4040
$dsn = (new Dsn('sqlsrv', 'localhost', 'yiitest'))->asString();
4141

42-
return new ConnectionPDO(
43-
new PDODriver($dsn, 'SA', 'YourStrong!Passw0rd'),
42+
return new Connection(
43+
new Driver($dsn, 'SA', 'YourStrong!Passw0rd'),
4444
DbHelper::getSchemaCache(),
4545
);
4646
}

0 commit comments

Comments
 (0)