Guest User

Untitled

a guest
Nov 4th, 2017
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. <?php
  2.  
  3. define('DB_HOST', 'db.service');
  4. define('DB_USER', 'docker');
  5. define('DB_PASS', 'mysql');
  6.  
  7. use \Amp\Loop;
  8. use \Amp\Mysql\Pool;
  9. use Aerys\{ Host, Request, Response, Websocket, function root, function router, function websocket };
  10.  
  11. return (new \Aerys\Host)->expose("*", 1337)->use(
  12. function(Request $req, Response $res) {
  13.  
  14. $strConn = "host=".DB_HOST.";user=".DB_USER.";pass=".DB_PASS;
  15. $sql = "SELECT * from mysql.user";
  16. $pool = new Pool($strConn);
  17. $resultSet = yield $pool->query($sql);
  18. $rows = yield $resultSet->fetchAll();
  19. $res->end("<html><body><h1>Fallback \o/</h1><p>".$sql."</p><p>Found: ". count($rows)." rows</p></body></html>");
  20. });
Add Comment
Please, Sign In to add comment