Skip to content

bqevin/react-mysql

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AsyncMysql

Asynchronous & non-blocking MySQL driver for React.PHP.

Install

Add this crap to your composer.json:

{
  "require": {
    "khr/react-mysql": "*"
  }
}

Usage

Create instance of AsyncMysql and call method query. It returns Promise of mysqli_result that will be resolved imediately after query completes.

<?php

$loop = React\EventLoop\Factory::create();

$makeConnection = function () {
  return mysqli_connect('localhost', 'user', 'pass', 'dbname');
};

$mysql = new \KHR\React\Mysql\Client($loop, new \KHR\React\Mysql\Pool(function(){
    return mysqli_connect('127.0.0.1', 'root', '', 'test');
}, 10));
$mysql->query('select * from ponies_and_unicorns')->then(
  function ($result) { writeHttpResponse(json_encode($result->all())); },
  function ($error)  { writeHeader500(); }
);

About

Asynchronous & non-blocking MySQL driver for React.PHP

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%