Skip to content

Commit

Permalink
Merge pull request #232 from srjlewis/6.x-docs
Browse files Browse the repository at this point in the history
Update 6.x docs to reflect latest changes
  • Loading branch information
koriym authored Dec 18, 2024
2 parents 0d02dd3 + 75e14ca commit 820ea99
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 2 deletions.
18 changes: 16 additions & 2 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ name, username, password, and driver options. There is one additional
parameter that allows you to pass attributes to be set after the connection is
made.

#### Creation using constructor
```php
use Aura\Sql\ExtendedPdo;

Expand All @@ -23,12 +24,25 @@ $pdo = new ExtendedPdo(
[] // queries to execute after connection
);
```
#### Creation using static factory
```php
use Aura\Sql\ExtendedPdo;

$pdo = ExtendedPdo::connect(
'mysql:host=localhost;dbname=test',
'username',
'password',
[], // driver attributes/options as key-value pairs
[] // queries to execute after connection
);
```


Whereas the native _PDO_ connects on instantiation, _ExtendedPdo_ does not
connect immediately. Instead, it connects only when you call a method that
actually needs the connection to the database; e.g., on `query()`.

If you want to force a connection, call the `connect()` method.
If you want to force a connection, call the `establishConnection()` method.

```php
// does not connect to the database
Expand All @@ -42,7 +56,7 @@ $pdo = new ExtendedPdo(
$pdo->exec('SELECT * FROM test');

// explicitly forces a connection
$pdo->connect();
$pdo->establishConnection();
```

If you want to explicitly force a disconnect, call the `disconnect()` method.
Expand Down
65 changes: 65 additions & 0 deletions docs/upgrade.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,68 @@
# 6.x Upgrade Notes

Most changes are to provide better compatability with PHP 8.4 and above.

With PHP 8.4 introducing `Pdo::connect()` as a way of creating driver specific connections.

We have introducing our `ExtendedPdo::connect()` which uses the underlining PDO features then with all our
normal added features.

```php
// does not connect to the database
$pdo = ExtendedPdo::connect(
'mysql:host=localhost;dbname=test',
'username',
'password'
);

// automatically connects
$pdo->exec('SELECT * FROM test');

// explicitly forces a connection
$pdo->establishConnection();
```

# 5.x Upgrade Notes

Most changes are to provide better typing and compatability with PHP 8.1 and above.

## Deprecations

The main change is the deprecation of `ExtendedPdo::connect()` and will be changed in future versions starting with 6.x

Older Code would look like ...

```php
// does not connect to the database
$pdo = new ExtendedPdo(
'mysql:host=localhost;dbname=test',
'username',
'password'
);

// automatically connects
$pdo->exec('SELECT * FROM test');

// explicitly forces a connection
$pdo->connect();
```
... and now needs to be changed to `ExtendedPdo::establishConnection()`

```php
// does not connect to the database
$pdo = new ExtendedPdo(
'mysql:host=localhost;dbname=test',
'username',
'password'
);

// automatically connects
$pdo->exec('SELECT * FROM test');

// explicitly forces a connection
$pdo->establishConnection();
```

# 3.x Upgrade Notes

The vast majority of changes and breaks from the 2.x version are "under the
Expand Down

0 comments on commit 820ea99

Please sign in to comment.