Skip to content

kaja47/async-mysql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AsyncMysql

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

Install

Add this crap to your composer.json:

{
  "require": {
    "atrox/async-mysql": "dev-master"
  },
  "repositories": [
    {
      "type": "vcs",
      "url": "https://github.com/kaja47/async-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 Atrox\AsyncMysql($loop, $makeConnection);
$mysql->query('select * from ponies_and_unicorns')->then(
  function ($result) { writeHttpResponse(json_encode($result->fetch_all(MYSQLI_ASSOC))); $result->close(); },
  function ($error)  { writeHeader500(); }
);

About

Asynchronous & non-blocking MySQL driver for React.PHP

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages