COMPRESS and UNCOMPRESS data for the database
-
Hi, I’m trying to save some space on the database when I store large size strings.
The idea is to use a compressor like the PHPgzcompress( $data )
when I store the data using:global $wpdb; $sql = " UPDATE table SET field = %s WHERE user_id = {$this->user_id} "; $sts = $wpdb->query( $wpdb->prepare( $sql, $data ) );
then when I need to get the data:
$sql = " SELECT field FROM table WHERE user_id = {$this->user_id} "; $dt = $wpdb->get_results( $sql, OBJECT );
and get the uncompressed data using
gzuncompress($st[0]->field)
.
Does anyone have any idea on how to do it without killing the database myself by injecting uncontrolled binary data?or eventually on how to use something like:
global $wpdb; $sql = " UPDATE table SET field = COMPRESS( %s ) WHERE user_id = {$this->user_id} "; $sts = $wpdb->query( $wpdb->prepare( $sql, $data ) );
to compress and:
$sql = " SELECT UNCOMPRESS( field ) FROM table WHERE user_id = {$this->user_id} "; $dt = $wpdb->get_results( $sql, OBJECT );
to uncompress?
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘COMPRESS and UNCOMPRESS data for the database’ is closed to new replies.