@@ -14,25 +14,29 @@ public function __construct(
1414 ) {
1515 }
1616
17- public function execute (): Id
17+ public function execute (mixed ... $ bindings ): Id
1818 {
19+ $ this ->bindings = [...$ this ->bindings , ...$ bindings ];
20+
1921 $ database = $ this ->getDatabase ();
2022
21- $ database ->execute ($ this );
23+ $ query = $ this ->withBindings ($ bindings );
24+
25+ $ database ->execute ($ query );
2226
23- return isset ($ this ->bindings ['id ' ])
24- ? new Id ($ this ->bindings ['id ' ])
27+ return isset ($ query ->bindings ['id ' ])
28+ ? new Id ($ query ->bindings ['id ' ])
2529 : $ database ->getLastInsertId ();
2630 }
2731
28- public function fetch (): array
32+ public function fetch (mixed ... $ bindings ): array
2933 {
30- return $ this ->getDatabase ()->fetch ($ this );
34+ return $ this ->getDatabase ()->fetch ($ this -> withBindings ( $ bindings ) );
3135 }
3236
33- public function fetchFirst (): ?array
37+ public function fetchFirst (mixed ... $ bindings ): ?array
3438 {
35- return $ this ->getDatabase ()->fetchFirst ($ this );
39+ return $ this ->getDatabase ()->fetchFirst ($ this -> withBindings ( $ bindings ) );
3640 }
3741
3842 public function getSql (): string
@@ -47,6 +51,15 @@ public function append(string $append): self
4751 return $ this ;
4852 }
4953
54+ public function withBindings (array $ bindings ): self
55+ {
56+ $ clone = clone $ this ;
57+
58+ $ clone ->bindings = [...$ clone ->bindings , ...$ bindings ];
59+
60+ return $ clone ;
61+ }
62+
5063 private function getDatabase (): Database
5164 {
5265 return get (Database::class);
0 commit comments