MySqlBitConnection.php 784 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * This file is part of Hyperf.
  5. *
  6. * @link https://www.hyperf.io
  7. * @document https://hyperf.wiki
  8. * @contact group@hyperf.io
  9. * @license https://github.com/hyperf/hyperf/blob/master/LICENSE
  10. */
  11. namespace Hyperf\Database;
  12. use PDO;
  13. use PDOStatement;
  14. class MySqlBitConnection extends MySqlConnection
  15. {
  16. public function bindValues(PDOStatement $statement, array $bindings): void
  17. {
  18. foreach ($bindings as $key => $value) {
  19. $type = PDO::PARAM_STR;
  20. if (in_array($value, [0, 1], true)) {
  21. $type = PDO::PARAM_INT;
  22. }
  23. $statement->bindValue(
  24. is_string($key) ? $key : $key + 1,
  25. $value,
  26. $type
  27. );
  28. }
  29. }
  30. }