Skip to content

Commit 7433b7e

Browse files
committed
Prepare v0.4.0 release
1 parent 701c22c commit 7433b7e

File tree

2 files changed

+148
-1
lines changed

2 files changed

+148
-1
lines changed

CHANGELOG.md

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,152 @@
11
# Changelog
22

3+
## 0.4.0 (2018-09-21)
4+
5+
A major feature release with a significant documentation overhaul and long overdue API cleanup!
6+
7+
This update involves a number of BC breaks due to various changes to make the
8+
API more consistent with the ReactPHP ecosystem. In particular, this now uses
9+
promises consistently as return values instead of accepting callback functions
10+
and this now offers an additional streaming API for processing very large result
11+
sets efficiently.
12+
13+
We realize that the changes listed below may seem a bit overwhelming, but we've
14+
tried to be very clear about any possible BC breaks. See below for changes you
15+
have to take care of when updating from an older version.
16+
17+
* Feature / BC break: Add Factory to simplify connecting and keeping connection state,
18+
mark `Connection` class as internal and remove `connect()` method.
19+
(#64 by @clue)
20+
21+
```php
22+
// old
23+
$connection = new Connection($loop, $options);
24+
$connection->connect(function (?Exception $error, $connection) {
25+
if ($error) {
26+
// an error occured while trying to connect or authorize client
27+
} else {
28+
// client connection established (and authenticated)
29+
}
30+
});
31+
32+
// new
33+
$factory = new Factory($loop);
34+
$factory->createConnection($url)->then(
35+
function (ConnectionInterface $connection) {
36+
// client connection established (and authenticated)
37+
},
38+
function (Exception $e) {
39+
// an error occured while trying to connect or authorize client
40+
}
41+
);
42+
```
43+
44+
* Feature / BC break: Use promises for `query()` method and resolve with `QueryResult` on success and
45+
and mark all commands as internal and move its base to Commands namespace.
46+
(#61 and #62 by @clue)
47+
48+
```php
49+
// old
50+
$connection->query('CREATE TABLE test');
51+
$connection->query('DELETE FROM user WHERE id < ?', $id);
52+
$connection->query('SELECT * FROM user', function (QueryCommand $command) {
53+
if ($command->hasError()) {
54+
echo 'Error: ' . $command->getError()->getMessage() . PHP_EOL;
55+
} elseif (isset($command->resultRows)) {
56+
var_dump($command->resultRows);
57+
}
58+
});
59+
60+
// new
61+
$connection->query('CREATE TABLE test');
62+
$connection->query('DELETE FROM user WHERE id < ?', [$id]);
63+
$connection->query('SELECT * FROM user')->then(function (QueryResult $result) {
64+
var_dump($result->resultRows);
65+
}, function (Exception $error) {
66+
echo 'Error: ' . $error->getMessage() . PHP_EOL;
67+
});
68+
```
69+
70+
* Feature / BC break: Add new `queryStream()` method to stream result set rows and
71+
remove undocumented "results" event.
72+
(#57 and #77 by @clue)
73+
74+
```php
75+
$stream = $connection->queryStream('SELECT * FROM users');
76+
77+
$stream->on('data', function ($row) {
78+
var_dump($row);
79+
});
80+
$stream->on('end', function () {
81+
echo 'DONE' . PHP_EOL;
82+
});
83+
```
84+
85+
* Feature / BC break: Rename `close()` to `quit()`, use promises for `quit()` method and
86+
add new `close()` method to force-close the connection.
87+
(#65 and #76 by @clue)
88+
89+
```php
90+
// old: soft-close/quit
91+
$connection->close(function () {
92+
echo 'closed';
93+
});
94+
95+
// new: soft-close/quit
96+
$connection->quit()->then(function () {
97+
echo 'closed';
98+
});
99+
100+
// new: force-close
101+
$connection->close();
102+
```
103+
104+
* Feature / BC break: Use promises for `ping()` method and resolve with void value on success.
105+
(#63 and #66 by @clue)
106+
107+
```php
108+
// old
109+
$connection->ping(function ($error, $connection) {
110+
if ($error) {
111+
echo 'Error: ' . $error->getMessage() . PHP_EOL;
112+
} else {
113+
echo 'OK' . PHP_EOL;
114+
}
115+
});
116+
117+
// new
118+
$connection->ping(function () {
119+
echo 'OK' . PHP_EOL;
120+
}, function (Exception $error) {
121+
echo 'Error: ' . $error->getMessage() . PHP_EOL;
122+
});
123+
```
124+
125+
* Feature / BC break: Define events on ConnectionInterface
126+
(#78 by @clue)
127+
128+
* BC break: Remove unneeded `ConnectionInterface` methods `getState()`,
129+
`getOptions()`, `setOptions()` and `getServerOptions()`, `selectDb()` and `listFields()` dummy.
130+
(#60 and #68 by @clue)
131+
132+
* BC break: Mark all protocol logic classes as internal and move to new Io namespace.
133+
(#53 and #62 by @clue)
134+
135+
* Fix: Fix executing queued commands in the order they are enqueued
136+
(#75 by @clue)
137+
138+
* Fix: Fix reading all incoming response packets until end
139+
(#59 by @clue)
140+
141+
* [maintenance] Internal refactoring to simplify connection and authentication logic
142+
(#69 by @clue)
143+
* [maintenance] Internal refactoring to remove unneeded references from Commands
144+
(#67 by @clue)
145+
* [maintenance] Internal refactoring to remove unneeded EventEmitter implementation and circular references
146+
(#56 by @clue)
147+
* [maintenance] Refactor internal parsing logic to separate Buffer class, remove dead code and improve performance
148+
(#54 by @clue)
149+
3150
## 0.3.3 (2018-06-18)
4151

5152
* Fix: Reject pending commands if connection is closed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ The recommended way to install this library is [through Composer](https://getcom
343343
This will install the latest supported version:
344344

345345
```bash
346-
$ composer require react/mysql:^0.3.3
346+
$ composer require react/mysql:^0.4
347347
```
348348

349349
See also the [CHANGELOG](CHANGELOG.md) for details about version upgrades.

0 commit comments

Comments
 (0)