本文整理汇总了PHP中Ak::uncompress方法的典型用法代码示例。如果您正苦于以下问题:PHP Ak::uncompress方法的具体用法?PHP Ak::uncompress怎么用?PHP Ak::uncompress使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ak
的用法示例。
在下文中一共展示了Ak::uncompress方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Test_of_compress_decompress
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);
}
示例2: decompress
function decompress($compressed_data, $format = 'gzip')
{
return Ak::uncompress($compressed_data, $format);
}
示例3: castAttributeFromDatabase
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;
}