|
1 | 1 | <?php declare(strict_types = 1); |
2 | 2 |
|
| 3 | +/* |
| 4 | + * phpcs:disable WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid |
| 5 | + * phpcs:disable Generic.Files.OneObjectStructurePerFile.MultipleFound |
| 6 | + */ |
| 7 | + |
3 | 8 | /** |
4 | 9 | * Cloudflare D1 connection. |
5 | 10 | * |
@@ -158,18 +163,27 @@ public function set_query_logger( $logger ): void { |
158 | 163 | */ |
159 | 164 | public function execute_remote( string $sql, array $params = array() ): array { |
160 | 165 | $url = rtrim( $this->api_base, '/' ) . '/accounts/' . rawurlencode( $this->account_id ) . '/d1/database/' . rawurlencode( $this->database_id ) . '/query'; |
161 | | - $body = json_encode( array( 'sql' => $sql, 'params' => array_values( $params ) ) ); |
| 166 | + $body = json_encode( |
| 167 | + array( |
| 168 | + 'sql' => $sql, |
| 169 | + 'params' => array_values( $params ), |
| 170 | + ) |
| 171 | + ); |
162 | 172 |
|
163 | 173 | $raw = null; |
164 | 174 | $code = 0; |
165 | 175 | if ( function_exists( 'curl_init' ) ) { |
166 | 176 | $ch = curl_init( $url ); |
167 | 177 | curl_setopt( $ch, CURLOPT_POST, true ); |
168 | 178 | curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); |
169 | | - curl_setopt( $ch, CURLOPT_HTTPHEADER, array( |
170 | | - 'Authorization: Bearer ' . $this->api_token, |
171 | | - 'Content-Type: application/json', |
172 | | - ) ); |
| 179 | + curl_setopt( |
| 180 | + $ch, |
| 181 | + CURLOPT_HTTPHEADER, |
| 182 | + array( |
| 183 | + 'Authorization: Bearer ' . $this->api_token, |
| 184 | + 'Content-Type: application/json', |
| 185 | + ) |
| 186 | + ); |
173 | 187 | curl_setopt( $ch, CURLOPT_POSTFIELDS, $body ); |
174 | 188 | curl_setopt( $ch, CURLOPT_TIMEOUT, 30 ); |
175 | 189 | $raw = curl_exec( $ch ); |
|
0 commit comments