PHP code example of tonix-tuft / reactphp-mysql-decorator

1. Go to this page and download the library: Download tonix-tuft/reactphp-mysql-decorator library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

tonix-tuft / reactphp-mysql-decorator example snippets




// ...
use React\EventLoop\Factory as LoopFactory;
use React\MySQL\Factory;
use ReactPHP\MySQL\Decorator\BindAssocParamsConnectionDecorator;

// ...
$loop = LoopFactory::create();
$factory = new Factory($loop);

$uri = 'username:password@localhost/dbname';
$connection = $factory->createLazyConnection($uri); // returns a React\MySQL\ConnectionInterface

$connectionWithBindAssocParams = new BindAssocParamsConnectionDecorator($connection);

// Now you can bind associative parameters when you execute your queries.
$value = 123;
$connectionWithBindAssocParams->query('SELECT * FROM table WHERE field = :value', [
   ':value' => $value
])->then(
   // ...
);