Raw.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. /**
  3. * This file is part of webman.
  4. *
  5. * Licensed under The MIT License
  6. * For full copyright and license information, please see the MIT-LICENSE.txt
  7. * Redistributions of files must retain the above copyright notice.
  8. *
  9. * @author walkor<[email protected]>
  10. * @copyright walkor<[email protected]>
  11. * @link http://www.workerman.net/
  12. * @license http://www.opensource.org/licenses/mit-license.php MIT License
  13. */
  14. namespace support\bootstrap\db;
  15. use Webman\Bootstrap;
  16. use Workerman\Worker;
  17. use PDOStatement;
  18. use PDO;
  19. /**
  20. * Class Raw
  21. * @package support\bootstrap\db
  22. */
  23. class Raw implements Bootstrap
  24. {
  25. public static PDO $pdo;
  26. public static PDOStatement $fortune;
  27. public static PDOStatement $random;
  28. /**
  29. * @param Worker $worker
  30. *
  31. * @return void
  32. */
  33. public static function start($worker)
  34. {
  35. $pdo = new PDO('pgsql:host=tfb-database;dbname=hello_world',
  36. 'benchmarkdbuser', 'benchmarkdbpass',
  37. [PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
  38. PDO::ATTR_EMULATE_PREPARES => false]
  39. );
  40. self::$random = $pdo->prepare('SELECT id,randomNumber FROM World WHERE id=?');
  41. self::$fortune = $pdo->prepare('SELECT id,message FROM Fortune');
  42. self::$pdo = $pdo;
  43. }
  44. }