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

Rename MySQL namespace to Mysql #188

Merged
merged 1 commit into from
Nov 29, 2023
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
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ This example runs a simple `SELECT` query and dumps all the records from a `book

require __DIR__ . '/vendor/autoload.php';

$mysql = new React\MySQL\MysqlClient('user:pass@localhost/bookstore');
$mysql = new React\Mysql\MysqlClient('user:pass@localhost/bookstore');

$mysql->query('SELECT * FROM book')->then(
function (React\MySQL\MysqlResult $command) {
function (React\Mysql\MysqlResult $command) {
print_r($command->resultFields);
print_r($command->resultRows);
echo count($command->resultRows) . ' row(s) in set' . PHP_EOL;
Expand All @@ -68,7 +68,7 @@ The `MysqlClient` is responsible for exchanging messages with your MySQL server
and keeps track of pending queries.

```php
$mysql = new React\MySQL\MysqlClient($uri);
$mysql = new React\Mysql\MysqlClient($uri);

$mysql->query(…);
```
Expand Down Expand Up @@ -114,7 +114,7 @@ The `$uri` parameter must contain the database host, optional
authentication, port and database to connect to:

```php
$mysql = new React\MySQL\MysqlClient('user:secret@localhost:3306/database');
$mysql = new React\Mysql\MysqlClient('user:secret@localhost:3306/database');
```

Note that both the username and password must be URL-encoded (percent-encoded)
Expand All @@ -124,15 +124,15 @@ if they contain special characters:
$user = 'he:llo';
$pass = 'p@ss';

$mysql = new React\MySQL\MysqlClient(
$mysql = new React\Mysql\MysqlClient(
rawurlencode($user) . ':' . rawurlencode($pass) . '@localhost:3306/db'
);
```

You can omit the port if you're connecting to default port `3306`:

```php
$mysql = new React\MySQL\MysqlClient('user:secret@localhost/database');
$mysql = new React\Mysql\MysqlClient('user:secret@localhost/database');
```

If you do not include authentication and/or database, then this method
Expand All @@ -141,7 +141,7 @@ and no database selected. This may be useful when initially setting up a
database, but likely to yield an authentication error in a production system:

```php
$mysql = new React\MySQL\MysqlClient('localhost');
$mysql = new React\Mysql\MysqlClient('localhost');
```

This method respects PHP's `default_socket_timeout` setting (default 60s)
Expand All @@ -150,7 +150,7 @@ successful authentication. You can explicitly pass a custom timeout value
in seconds (or use a negative number to not apply a timeout) like this:

```php
$mysql = new React\MySQL\MysqlClient('localhost?timeout=0.5');
$mysql = new React\Mysql\MysqlClient('localhost?timeout=0.5');
```

By default, idle connections will be held open for 1ms (0.001s) when not
Expand All @@ -163,7 +163,7 @@ pass a custom idle timeout value in seconds (or use a negative number to
not apply a timeout) like this:

```php
$mysql = new React\MySQL\MysqlClient('localhost?idle=10.0');
$mysql = new React\Mysql\MysqlClient('localhost?idle=10.0');
```

By default, the connection provides full UTF-8 support (using the
Expand All @@ -172,7 +172,7 @@ applications nowadays, but for legacy reasons you can change this to use
a different ASCII-compatible charset encoding like this:

```php
$mysql = new React\MySQL\MysqlClient('localhost?charset=utf8mb4');
$mysql = new React\Mysql\MysqlClient('localhost?charset=utf8mb4');
```

If you need custom connector settings (DNS resolution, TLS parameters, timeouts,
Expand All @@ -191,7 +191,7 @@ $connector = new React\Socket\Connector([
)
]);

$mysql = new React\MySQL\MysqlClient('user:secret@localhost:3306/database', $connector);
$mysql = new React\Mysql\MysqlClient('user:secret@localhost:3306/database', $connector);
```

This class takes an optional `LoopInterface|null $loop` parameter that can be used to
Expand Down Expand Up @@ -225,7 +225,7 @@ unknown or known to be too large to fit into memory, you should use the
[`queryStream()`](#querystream) method instead.

```php
$mysql->query($query)->then(function (React\MySQL\MysqlResult $command) {
$mysql->query($query)->then(function (React\Mysql\MysqlResult $command) {
if (isset($command->resultRows)) {
// this is a response to a SELECT etc. with some rows (0+)
print_r($command->resultFields);
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
},
"autoload": {
"psr-4": {
"React\\MySQL\\": "src/"
"React\\Mysql\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"React\\Tests\\MySQL\\": "tests/"
"React\\Tests\\Mysql\\": "tests/"
}
}
}
4 changes: 2 additions & 2 deletions examples/01-query.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

require __DIR__ . '/../vendor/autoload.php';

$mysql = new React\MySQL\MysqlClient(getenv('MYSQL_URI') ?: 'test:test@localhost/test');
$mysql = new React\Mysql\MysqlClient(getenv('MYSQL_URI') ?: 'test:test@localhost/test');

$query = isset($argv[1]) ? $argv[1] : 'select * from book';
$mysql->query($query)->then(function (React\MySQL\MysqlResult $command) {
$mysql->query($query)->then(function (React\Mysql\MysqlResult $command) {
if (isset($command->resultRows)) {
// this is a response to a SELECT etc. with some rows (0+)
print_r($command->resultFields);
Expand Down
2 changes: 1 addition & 1 deletion examples/02-query-stream.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

require __DIR__ . '/../vendor/autoload.php';

$mysql = new React\MySQL\MysqlClient(getenv('MYSQL_URI') ?: 'test:test@localhost/test');
$mysql = new React\Mysql\MysqlClient(getenv('MYSQL_URI') ?: 'test:test@localhost/test');

$query = isset($argv[1]) ? $argv[1] : 'select * from book';
$stream = $mysql->queryStream($query);
Expand Down
4 changes: 2 additions & 2 deletions examples/11-interactive.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

require __DIR__ . '/../vendor/autoload.php';

$mysql = new React\MySQL\MysqlClient(getenv('MYSQL_URI') ?: 'test:test@localhost/test');
$mysql = new React\Mysql\MysqlClient(getenv('MYSQL_URI') ?: 'test:test@localhost/test');

// open a STDIN stream to read keyboard input (not supported on Windows)
$stdin = new React\Stream\ReadableResourceStream(STDIN);
Expand All @@ -25,7 +25,7 @@
}

$time = microtime(true);
$mysql->query($query)->then(function (React\MySQL\MysqlResult $command) use ($time) {
$mysql->query($query)->then(function (React\Mysql\MysqlResult $command) use ($time) {
if (isset($command->resultRows)) {
// this is a response to a SELECT etc. with some rows (0+)
echo implode("\t", array_column($command->resultFields, 'name')) . PHP_EOL;
Expand Down
4 changes: 2 additions & 2 deletions examples/12-slow-stream.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

require __DIR__ . '/../vendor/autoload.php';

$mysql = new React\MySQL\MysqlClient(getenv('MYSQL_URI') ?: 'test:test@localhost/test');
$mysql = new React\Mysql\MysqlClient(getenv('MYSQL_URI') ?: 'test:test@localhost/test');

$query = isset($argv[1]) ? $argv[1] : 'select * from book';
$stream = $mysql->queryStream($query);
Expand All @@ -17,7 +17,7 @@
$promise = $ref->getValue($mysql);
assert($promise instanceof React\Promise\PromiseInterface);

$promise->then(function (React\MySQL\Io\Connection $connection) {
$promise->then(function (React\Mysql\Io\Connection $connection) {
// The protocol parser reads rather large chunks from the underlying connection
// and as such can yield multiple (dozens to hundreds) rows from a single data
// chunk. We try to artificially limit the stream chunk size here to try to
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/AbstractCommand.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace React\MySQL\Commands;
namespace React\Mysql\Commands;

use Evenement\EventEmitter;

Expand Down
8 changes: 4 additions & 4 deletions src/Commands/AuthenticateCommand.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

namespace React\MySQL\Commands;
namespace React\Mysql\Commands;

use React\MySQL\Io\Buffer;
use React\MySQL\Io\Constants;
use React\Mysql\Io\Buffer;
use React\Mysql\Io\Constants;

/**
* @internal
Expand Down Expand Up @@ -31,7 +31,7 @@ class AuthenticateCommand extends AbstractCommand
*
* @var array<string,int>
* @see self::$charsetNumber
* @see \React\MySQL\Io\Query::$escapeChars
* @see \React\Mysql\Io\Query::$escapeChars
*/
private static $charsetMap = [
'latin1' => 8,
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/CommandInterface.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace React\MySQL\Commands;
namespace React\Mysql\Commands;

use Evenement\EventEmitterInterface;

Expand Down
2 changes: 1 addition & 1 deletion src/Commands/PingCommand.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace React\MySQL\Commands;
namespace React\Mysql\Commands;

/**
* @internal
Expand Down
4 changes: 2 additions & 2 deletions src/Commands/QueryCommand.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

namespace React\MySQL\Commands;
namespace React\Mysql\Commands;

use React\MySQL\Io\Query;
use React\Mysql\Io\Query;

/**
* @internal
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/QuitCommand.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace React\MySQL\Commands;
namespace React\Mysql\Commands;

/**
* @internal
Expand Down
2 changes: 1 addition & 1 deletion src/Exception.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace React\MySQL;
namespace React\Mysql;

class Exception extends \Exception
{
Expand Down
2 changes: 1 addition & 1 deletion src/Io/Buffer.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
namespace React\MySQL\Io;
namespace React\Mysql\Io;

/**
* @internal
Expand Down
16 changes: 8 additions & 8 deletions src/Io/Connection.php
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
<?php

namespace React\MySQL\Io;
namespace React\Mysql\Io;

use Evenement\EventEmitter;
use React\MySQL\Commands\CommandInterface;
use React\MySQL\Commands\PingCommand;
use React\MySQL\Commands\QueryCommand;
use React\MySQL\Commands\QuitCommand;
use React\MySQL\Exception;
use React\MySQL\MysqlResult;
use React\Mysql\Commands\CommandInterface;
use React\Mysql\Commands\PingCommand;
use React\Mysql\Commands\QueryCommand;
use React\Mysql\Commands\QuitCommand;
use React\Mysql\Exception;
use React\Mysql\MysqlResult;
use React\Promise\Deferred;
use React\Promise\Promise;
use React\Socket\ConnectionInterface as SocketConnectionInterface;

/**
* @internal
* @see \React\MySQL\MysqlClient
* @see \React\Mysql\MysqlClient
*/
class Connection extends EventEmitter
{
Expand Down
2 changes: 1 addition & 1 deletion src/Io/Constants.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace React\MySQL\Io;
namespace React\Mysql\Io;

/**
* @internal
Expand Down
2 changes: 1 addition & 1 deletion src/Io/Executor.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace React\MySQL\Io;
namespace React\Mysql\Io;

use Evenement\EventEmitter;

Expand Down
12 changes: 6 additions & 6 deletions src/Io/Factory.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php

namespace React\MySQL\Io;
namespace React\Mysql\Io;

use React\EventLoop\Loop;
use React\EventLoop\LoopInterface;
use React\MySQL\Commands\AuthenticateCommand;
use React\MySQL\Exception;
use React\Mysql\Commands\AuthenticateCommand;
use React\Mysql\Exception;
use React\Promise\Deferred;
use React\Promise\PromiseInterface;
use React\Promise\Timer\TimeoutException;
Expand All @@ -15,7 +15,7 @@

/**
* @internal
* @see \React\MySQL\MysqlClient
* @see \React\Mysql\MysqlClient
*/
class Factory
{
Expand All @@ -29,7 +29,7 @@ class Factory
* The `Factory` is responsible for creating an internal `Connection` instance.
*
* ```php
* $factory = new React\MySQL\Io\Factory();
* $factory = new React\Mysql\Io\Factory();
* ```
*
* This class takes an optional `LoopInterface|null $loop` parameter that can be used to
Expand All @@ -54,7 +54,7 @@ class Factory
* ]
* ]);
*
* $factory = new React\MySQL\Factory(null, $connector);
* $factory = new React\Mysql\Factory(null, $connector);
* ```
*
* @param ?LoopInterface $loop
Expand Down
12 changes: 6 additions & 6 deletions src/Io/Parser.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php

namespace React\MySQL\Io;
namespace React\Mysql\Io;

use React\MySQL\Commands\AuthenticateCommand;
use React\MySQL\Commands\QueryCommand;
use React\MySQL\Commands\QuitCommand;
use React\MySQL\Exception as MysqlException;
use React\Mysql\Commands\AuthenticateCommand;
use React\Mysql\Commands\QueryCommand;
use React\Mysql\Commands\QuitCommand;
use React\Mysql\Exception as MysqlException;
use React\Stream\DuplexStreamInterface;

/**
Expand Down Expand Up @@ -46,7 +46,7 @@ class Parser
* next command from the `Executor` queue. If no command is outstanding,
* this will be reset to the `null` state.
*
* @var \React\MySQL\Commands\AbstractCommand|null
* @var \React\Mysql\Commands\AbstractCommand|null
*/
protected $currCommand;

Expand Down
4 changes: 2 additions & 2 deletions src/Io/Query.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace React\MySQL\Io;
namespace React\Mysql\Io;

/**
* @internal
Expand All @@ -25,7 +25,7 @@ class Query
* as long as this class is only used internally for the `query()` method.
*
* @var array<string,string>
* @see \React\MySQL\Commands\AuthenticateCommand::$charsetMap
* @see \React\Mysql\Commands\AuthenticateCommand::$charsetMap
*/
private $escapeChars = [
//"\x00" => "\\0",
Expand Down
4 changes: 2 additions & 2 deletions src/Io/QueryStream.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

namespace React\MySQL\Io;
namespace React\Mysql\Io;

use Evenement\EventEmitter;
use React\MySQL\Commands\QueryCommand;
use React\Mysql\Commands\QueryCommand;
use React\Socket\ConnectionInterface;
use React\Stream\ReadableStreamInterface;
use React\Stream\Util;
Expand Down
Loading