1212use SimPod \ClickHouseClient \Client \Http \RequestOptions ;
1313use SimPod \ClickHouseClient \Exception \CannotInsert ;
1414use SimPod \ClickHouseClient \Exception \ServerError ;
15- use SimPod \ClickHouseClient \Exception \UnsupportedValue ;
15+ use SimPod \ClickHouseClient \Exception \UnsupportedParamType ;
16+ use SimPod \ClickHouseClient \Exception \UnsupportedParamValue ;
1617use SimPod \ClickHouseClient \Format \Format ;
1718use SimPod \ClickHouseClient \Output \Output ;
1819use SimPod \ClickHouseClient \Sql \Escaper ;
@@ -46,13 +47,18 @@ public function __construct(
4647
4748 public function executeQuery (string $ query , array $ settings = []): void
4849 {
49- $ this ->executeRequest ($ query , settings: $ settings );
50+ try {
51+ $ this ->executeRequest ($ query , params: [], settings: $ settings );
52+ } catch (UnsupportedParamType ) {
53+ absurd ();
54+ }
5055 }
5156
5257 public function executeQueryWithParams (string $ query , array $ params , array $ settings = []): void
5358 {
5459 $ this ->executeRequest (
5560 $ this ->sqlFactory ->createWithParameters ($ query , $ params ),
61+ params: $ params ,
5662 settings: $ settings ,
5763 );
5864 }
@@ -61,7 +67,7 @@ public function select(string $query, Format $outputFormat, array $settings = []
6167 {
6268 try {
6369 return $ this ->selectWithParams ($ query , params: [], outputFormat: $ outputFormat , settings: $ settings );
64- } catch (UnsupportedValue ) {
70+ } catch (UnsupportedParamValue | UnsupportedParamType ) {
6571 absurd ();
6672 }
6773 }
@@ -77,6 +83,7 @@ public function selectWithParams(string $query, array $params, Format $outputFor
7783 $ sql
7884 $ formatClause
7985 CLICKHOUSE ,
86+ params: $ params ,
8087 settings: $ settings ,
8188 );
8289
@@ -112,14 +119,19 @@ public function insert(string $table, array $values, array|null $columns = null,
112119
113120 $ table = Escaper::quoteIdentifier ($ table );
114121
115- $ this ->executeRequest (
116- <<<CLICKHOUSE
117- INSERT INTO $ table
118- $ columnsSql
119- VALUES $ valuesSql
120- CLICKHOUSE ,
121- settings: $ settings ,
122- );
122+ try {
123+ $ this ->executeRequest (
124+ <<<CLICKHOUSE
125+ INSERT INTO $ table
126+ $ columnsSql
127+ VALUES $ valuesSql
128+ CLICKHOUSE ,
129+ params: [],
130+ settings: $ settings ,
131+ );
132+ } catch (UnsupportedParamType ) {
133+ absurd ();
134+ }
123135 }
124136
125137 public function insertWithFormat (string $ table , Format $ inputFormat , string $ data , array $ settings = []): void
@@ -128,25 +140,33 @@ public function insertWithFormat(string $table, Format $inputFormat, string $dat
128140
129141 $ table = Escaper::quoteIdentifier ($ table );
130142
131- $ this ->executeRequest (
132- <<<CLICKHOUSE
133- INSERT INTO $ table $ formatSql $ data
134- CLICKHOUSE ,
135- settings: $ settings ,
136- );
143+ try {
144+ $ this ->executeRequest (
145+ <<<CLICKHOUSE
146+ INSERT INTO $ table $ formatSql $ data
147+ CLICKHOUSE ,
148+ params: [],
149+ settings: $ settings ,
150+ );
151+ } catch (UnsupportedParamType ) {
152+ absurd ();
153+ }
137154 }
138155
139156 /**
157+ * @param array<string, mixed> $params
140158 * @param array<string, float|int|string> $settings
141159 *
142160 * @throws ServerError
143161 * @throws ClientExceptionInterface
162+ * @throws UnsupportedParamType
144163 */
145- private function executeRequest (string $ sql , array $ settings ): ResponseInterface
164+ private function executeRequest (string $ sql , array $ params , array $ settings ): ResponseInterface
146165 {
147166 $ request = $ this ->requestFactory ->prepareRequest (
148167 new RequestOptions (
149168 $ sql ,
169+ $ params ,
150170 $ this ->defaultSettings ,
151171 $ settings ,
152172 ),
0 commit comments