@@ -272,20 +272,32 @@ public function testDeallocatePreparedQueryThenTryToClose(): void
272272
273273 public function testInsertBinaryData (): void
274274 {
275- if ($ this ->db ->DBDriver === 'Postgre ' || $ this ->db ->DBDriver === 'SQLSRV ' ) {
276- $ this ->markTestSkipped ('Blob not supported for Postgre and SQLSRV. ' );
275+ $ params = [];
276+ if ($ this ->db ->DBDriver === 'SQLSRV ' ) {
277+ $ params = [0 => SQLSRV_PHPTYPE_STREAM (SQLSRV_ENC_BINARY )];
277278 }
278279
279280 $ this ->query = $ this ->db ->prepare (static fn ($ db ) => $ db ->table ('type_test ' )->insert ([
280281 'type_blob ' => 'binary ' ,
281- ]));
282+ ]), $ params );
282283
283284 $ fileContent = file_get_contents (TESTPATH . '_support/Images/EXIFsamples/landscape_0.jpg ' );
284285 $ this ->assertTrue ($ this ->query ->execute ($ fileContent ));
285286
286- $ id = $ this ->db ->insertId ();
287- $ file = $ this ->db ->table ('type_test ' )->where ('id ' , $ id )->get ()->getRow ();
287+ $ id = $ this ->db ->insertId ();
288+ $ builder = $ this ->db ->table ('type_test ' );
289+
290+ if ($ this ->db ->DBDriver === 'Postgre ' ) {
291+ $ file = $ builder ->select ("ENCODE(type_blob, 'base64') AS type_blob " )->where ('id ' , $ id )->get ()->getRow ();
292+ $ file = base64_decode ($ file ->type_blob , true );
293+ } elseif ($ this ->db ->DBDriver === 'OCI8 ' ) {
294+ $ file = $ builder ->select ('type_blob ' )->where ('id ' , $ id )->get ()->getRow ();
295+ $ file = $ file ->type_blob ->load ();
296+ } else {
297+ $ file = $ builder ->select ('type_blob ' )->where ('id ' , $ id )->get ()->getRow ();
298+ $ file = $ file ->type_blob ;
299+ }
288300
289- $ this ->assertSame (strlen ($ fileContent ), strlen ($ file-> type_blob ));
301+ $ this ->assertSame (strlen ($ fileContent ), strlen ($ file ));
290302 }
291303}
0 commit comments