Ejemplo n.º 1
0
 public function Test_of_compress_decompress()
 {
     $original = file_get_contents(__FILE__);
     $compressed = Ak::compress($original);
     file_put_contents(AK_TMP_DIR . DS . 'gzip_test.gz', $compressed);
     $this->assertTrue(strlen($compressed) < strlen($original));
     $compressed_file = file_get_contents(AK_TMP_DIR . DS . 'gzip_test.gz');
     $this->assertEqual($compressed_file, $compressed);
     $uncompressed_from_file = Ak::uncompress($compressed_file);
     $uncompressed_from_string = Ak::uncompress($compressed);
     $this->assertEqual($uncompressed_from_file, $uncompressed_from_string);
 }
Ejemplo n.º 2
0
Archivo: Ak.php Proyecto: joeymetal/v1
 function decompress($compressed_data, $format = 'gzip')
 {
     return Ak::uncompress($compressed_data, $format);
 }
Ejemplo n.º 3
0
 public function castAttributeFromDatabase($column_name, $value)
 {
     if ($this->hasColumn($column_name)) {
         $column_type = $this->getColumnType($column_name);
         if ($column_type) {
             if ('integer' == $column_type) {
                 return is_null($value) ? null : (int) $value;
                 //return is_null($value) ? null : $value;    // maybe for bigint we can do this
             } elseif ('boolean' == $column_type) {
                 if (is_null($value)) {
                     return null;
                 }
                 if ($this->getDatabaseType() == 'postgre') {
                     return $value == 't' ? true : false;
                 }
                 return (int) $value === 1 ? true : false;
             } elseif (!empty($value) && 'date' == $column_type && strstr(trim($value), ' ')) {
                 return substr($value, 0, 10) == '0000-00-00' ? null : str_replace(substr($value, strpos($value, ' ')), '', $value);
             } elseif (!empty($value) && 'datetime' == $column_type && substr($value, 0, 10) == '0000-00-00') {
                 return null;
             } elseif ('binary' == $column_type && $this->getDatabaseType() == 'postgre') {
                 $value = $this->_db->unescape_blob($value);
                 $value = empty($value) || trim($value) == 'null' ? null : $value;
                 if (!empty($value) && $this->_shouldCompressColumn($column_name)) {
                     $value = Ak::uncompress($value);
                 }
             } elseif ($this->_shouldSerializeColumn($column_name) && is_string($value)) {
                 $this->_ensureClassExistsForSerializedColumnBeforeUnserializing($column_name);
                 $value = @unserialize($value);
             }
         }
     }
     return $value;
 }