| Total Complexity | 9 |
| Total Lines | 95 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 6 | class QueryStatement extends Statement |
||
| 7 | { |
||
| 8 | use PrepareTrait; |
||
| 9 | |||
| 10 | protected $withKey = null; |
||
| 11 | |||
| 12 | /** |
||
| 13 | * 创建写 |
||
| 14 | * |
||
| 15 | * @param string $query |
||
| 16 | * @param array $args |
||
| 17 | */ |
||
| 18 | public function __construct(string $query, ...$args) |
||
| 19 | { |
||
| 20 | parent::__construct($query, ...$args); |
||
| 21 | $this->type = self::READ; |
||
| 22 | $this->fetch = self::FETCH_ONE; |
||
| 23 | $this->middleware = new NullMiddleware; |
||
| 24 | } |
||
| 25 | |||
| 26 | /** |
||
| 27 | * 设置取一条记录 |
||
| 28 | * |
||
| 29 | * @param string|null $class |
||
| 30 | * @param array $args |
||
| 31 | * @return $this |
||
| 32 | */ |
||
| 33 | public function wantOne(?string $class = null, array $args = []) |
||
| 34 | { |
||
| 35 | $this->fetch = self::FETCH_ONE; |
||
| 36 | if ($class !== null) { |
||
| 37 | $this->setFetchType($class, $args); |
||
| 38 | } |
||
| 39 | return $this; |
||
| 40 | } |
||
| 41 | |||
| 42 | /** |
||
| 43 | * 设置取全部记录 |
||
| 44 | * |
||
| 45 | * @param string|null $class |
||
| 46 | * @param array $args |
||
| 47 | * @return $this |
||
| 48 | */ |
||
| 49 | public function wantAll(?string $class = null, array $args = []) |
||
| 56 | } |
||
| 57 | |||
| 58 | /** |
||
| 59 | * 设置取值类 |
||
| 60 | * |
||
| 61 | * @param string|null $class |
||
| 62 | * @param array $args |
||
| 63 | * @return $this |
||
| 64 | */ |
||
| 65 | public function wantType(?string $class = null, array $args = []) |
||
| 66 | { |
||
| 67 | $this->setFetchType($class, $args); |
||
| 68 | return $this; |
||
| 69 | } |
||
| 70 | |||
| 71 | /** |
||
| 72 | * 设置使用某个字段做Key |
||
| 73 | * |
||
| 74 | * @param string $key |
||
| 75 | * @return $this |
||
| 76 | */ |
||
| 77 | public function withKey(string $key) |
||
| 78 | { |
||
| 79 | $this->withKey = $key; |
||
| 80 | $this->wantAll(); |
||
| 81 | return $this; |
||
| 82 | } |
||
| 83 | |||
| 84 | /** |
||
| 85 | * Get the value of withKey |
||
| 86 | */ |
||
| 87 | public function getWithKey() |
||
| 90 | } |
||
| 91 | |||
| 92 | /** |
||
| 93 | * 滚动获取 |
||
| 94 | * |
||
| 95 | * @return $this |
||
| 96 | */ |
||
| 97 | public function scroll() |
||
| 101 | } |
||
| 102 | } |
||
| 103 |