ConFoo Montreal 2026: Call for Papers

Voting

: min(eight, two)?
(Example: nine)

The Note You're Voting On

gabriel at bumpt dot n-et
17 years ago
To uncompress in PHP a string that has been compressed using MySQL's COMPRESS() function, you need to discard the first four bytes of the binary data:

<?php

/*
* Example:
*
* insert into mytable (myfield, ...) values (COMPRESS('foobar'), ...)
*
* then:
*/
$compressed = //...select myfield from mytable where...
/*
* then:
*/
$uncompressed = gzuncompress(substr($compressed, 4));
?>

Of course, you can use MySQL's UNCOMPRESS() function.
I was just providing an alternate method.

<< Back to user notes page

To Top