Reputation: 7954
I have a mysql table with a field and I don't have the permission to modify the table schema.
content varchar (255) not null
is there anyway to insert string with more size(greater than 255) to this field. I dont care how its stored(compressed or encoded). I want to retrieve the uncompressed one if it is compressed.
things I tried
gzcompress();
base64_encode();
<?php
$compressed = gzcompress('asdasdwq3eryt238774284873246827364872687342873rweuydfgjshdbfdgfgs', 9);
$uncompressed = gzuncompress($compressed);
echo $compressed.'---'.strlen($compressed);
echo "<br />";
echo $uncompressed.'----'.strlen($uncompressed);
//BOTH ARE SAME IN SIZE
?>
Upvotes: 1
Views: 340
Reputation: 7791
gzcompress compresses the given string using the ZLIB data format. For details on the ZLIB compression algorithm see the document ZLIB Compressed Data Format Specification version 3.3 (RFC 1950)
You can read one explanation of how ZLIB works in:
<?php
$compressed = gzcompress(' This function compresses the given string using the ZLIB data format. For details on the ZLIB compression algorithm see the document "» ZLIB Compressed Data Format Specification version 3.3" (RFC 1950). ', 9);
$uncompressed = gzuncompress($compressed);
echo $compressed.'---'.strlen($compressed);
echo "<br />";
echo $uncompressed.'----'.strlen($uncompressed);
?>
Upvotes: 1