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

Update 6.x docs to reflect latest changes #232

Merged
merged 1 commit into from
Dec 18, 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
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
Loading