DbConnection.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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\DbConnection\Traits;
  12. use Closure;
  13. use Generator;
  14. use Hyperf\Database\Query\Builder;
  15. use Hyperf\Database\Query\Expression;
  16. /**
  17. * TODO: release connection except transaction.
  18. */
  19. trait DbConnection
  20. {
  21. public function table($table): Builder
  22. {
  23. return $this->__call(__FUNCTION__, func_get_args());
  24. }
  25. public function raw($value): Expression
  26. {
  27. return $this->__call(__FUNCTION__, func_get_args());
  28. }
  29. public function selectOne($query, $bindings = [], $useReadPdo = true)
  30. {
  31. return $this->__call(__FUNCTION__, func_get_args());
  32. }
  33. public function select($query, $bindings = [], $useReadPdo = true): array
  34. {
  35. return $this->__call(__FUNCTION__, func_get_args());
  36. }
  37. public function cursor($query, $bindings = [], $useReadPdo = true): Generator
  38. {
  39. return $this->__call(__FUNCTION__, func_get_args());
  40. }
  41. public function insert($query, $bindings = []): bool
  42. {
  43. return $this->__call(__FUNCTION__, func_get_args());
  44. }
  45. public function update($query, $bindings = []): int
  46. {
  47. return $this->__call(__FUNCTION__, func_get_args());
  48. }
  49. public function delete($query, $bindings = []): int
  50. {
  51. return $this->__call(__FUNCTION__, func_get_args());
  52. }
  53. public function statement($query, $bindings = []): bool
  54. {
  55. return $this->__call(__FUNCTION__, func_get_args());
  56. }
  57. public function affectingStatement($query, $bindings = []): int
  58. {
  59. return $this->__call(__FUNCTION__, func_get_args());
  60. }
  61. public function unprepared($query): bool
  62. {
  63. return $this->__call(__FUNCTION__, func_get_args());
  64. }
  65. public function prepareBindings(array $bindings): array
  66. {
  67. return $this->__call(__FUNCTION__, func_get_args());
  68. }
  69. public function transaction(Closure $callback, $attempts = 1)
  70. {
  71. return $this->__call(__FUNCTION__, func_get_args());
  72. }
  73. public function beginTransaction(): void
  74. {
  75. $this->__call(__FUNCTION__, func_get_args());
  76. }
  77. public function commit(): void
  78. {
  79. $this->__call(__FUNCTION__, func_get_args());
  80. }
  81. public function rollBack(): void
  82. {
  83. $this->__call(__FUNCTION__, func_get_args());
  84. }
  85. public function transactionLevel(): int
  86. {
  87. return $this->__call(__FUNCTION__, func_get_args());
  88. }
  89. public function pretend(Closure $callback): array
  90. {
  91. return $this->__call(__FUNCTION__, func_get_args());
  92. }
  93. }