@@ -33,16 +33,16 @@ class Query
3333 private int $ rows = 100 ;
3434 private ?string $ correlationId = null ;
3535
36- public function __construct (SQLJob $ job , string $ sql , ?array $ options )
36+ public function __construct (SQLJob $ job , string $ sql , ?QueryOptions $ options )
3737 {
3838 $ this ->job = $ job ;
3939 $ this ->sql = $ sql ;
4040
4141 $ options = $ options ?? [];
42- $ this ->parameters = $ options[ ' parameters ' ] ?? [];
43- $ this ->isPrepared = !empty ($ options[ ' parameters ' ] );
44- $ this ->isClCommand = $ options[ ' isClCommand ' ] ?? false ;
45- $ this ->isTerseResults = $ options[ ' isTerseResults ' ] ?? false ;
42+ $ this ->parameters = $ options-> parameters ?? [];
43+ $ this ->isPrepared = !empty ($ options-> parameters );
44+ $ this ->isClCommand = $ options-> isClCommand ?? false ;
45+ $ this ->isTerseResults = $ options-> isTerseResults ?? false ;
4646
4747 self ::$ globalQueryList [] = $ this ;
4848 }
@@ -86,7 +86,7 @@ public function prepareSqlExecute(): array
8686 }
8787 if (count ($ errorList ) == 0 )
8888 $ errorList ['error ' ] = "failed to run query for unknown reason " ;
89- throw new \RunetimeException (json_encode ($ errorList ));
89+ throw new \RuntimeException (json_encode ($ errorList ));
9090 }
9191
9292 $ isDone = (bool )($ results ['is_done ' ] ?? false );
@@ -97,7 +97,7 @@ public function prepareSqlExecute(): array
9797 return $ results ;
9898 }
9999
100- public function run (int $ rows = null ): array
100+ public function run (? int $ rows = null ): array
101101 {
102102 if ($ rows == null )
103103 $ rows = $ this ->rows ;
@@ -128,7 +128,7 @@ public function run(int $rows = null): array
128128 'parameters ' => $ this ->parameters ,
129129 ];
130130
131- $ results = executeQuery ($ queryObject );
131+ $ results = $ this -> executeQuery ($ queryObject );
132132
133133 $ success = (bool )($ results ['success ' ] ?? false );
134134 if (!$ success && !$ this ->isClCommand ) {
@@ -141,7 +141,7 @@ public function run(int $rows = null): array
141141 }
142142 if (count ($ errorList ) == 0 )
143143 $ errorList ['error ' ] = "failed to run query for unknown reason " ;
144- throw new \RunetimeException (json_encode ($ errorList ));
144+ throw new \RuntimeException (json_encode ($ errorList ));
145145 }
146146
147147 $ isDone = (bool )($ results ['is_done ' ] ?? false );
@@ -174,12 +174,12 @@ public function fetchMore(int $rows): array
174174 ];
175175
176176 $ this ->rows = $ rows ;
177- $ results = executeQuery ($ queryObject );
177+ $ results = $ this -> executeQuery ($ queryObject );
178178
179179 $ success = (bool )($ results ['success ' ] ?? false );
180180 if (!$ success && !$ this ->isClCommand ) {
181181 $ this ->state = QueryState::ERROR ;
182- throw new \RunetimeException (($ results ['error ' ] ?? "Failed to run Query (unknown error) " ));
182+ throw new \RuntimeException (($ results ['error ' ] ?? "Failed to run Query (unknown error) " ));
183183 }
184184
185185 $ isDone = (bool )($ results ['is_done ' ] ?? false );
@@ -204,4 +204,14 @@ public function close(): array
204204 elseif (!$ this ->correlationId )
205205 $ this ->state = QueryState::RUN_DONE ;
206206 }
207+
208+ public function getId (): string
209+ {
210+ return $ this ->correlationId ;
211+ }
212+
213+ public function getState (): QueryState
214+ {
215+ return $ this ->state ;
216+ }
207217}
0 commit comments