2808 explained code solutions for 75 technologies


php-swooleMysql (PDO) connect and query example


Co\run(function() {

  $pdo = new PDO('mysql:host=localhost', 'root', '');

  go(function () use ($pdo) {
    $st = $pdo->prepare("SELECT now()");
    $st->execute([]);
    print_r($st->fetch());
  });

});ctrl + c
new PDO

connect to mysql server based on given config

go(

execute async code

"SELECT now()"

SQL query to execute

print_r($st->fetch())

prints result from Mysql server