Created
June 10, 2013 11:29
-
-
Save rinatio/5748116 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$db = $this->getContext()->getDB(); | |
$dbConf = $this->getContext()->getConf()->database; | |
$dbh = new PDO("mysql:host=$dbConf->host;dbname=$dbConf->database", $dbConf->username, $dbConf->password); | |
$sql = "update runresults set report_html = :report where id = :id"; | |
$q = $dbh->prepare($sql); | |
$q->execute(array( | |
':report'=>gzencode('hello'), | |
':id'=> 1052 | |
)); | |
$sql="SELECT report_html FROM runresults WHERE id = 1052"; | |
$result = $dbh->query($sql); | |
$row = $result->fetch(PDO::FETCH_NUM); | |
// Example 1 | |
// report_html is not encoded properly that's why we see an error in browser | |
header( 'Content-Encoding: gzip' ); | |
echo $row[0]; | |
// Example 2 | |
// This code throws a warning saying "error in data" | |
echo gzdecode($row[0]); | |
// Example 3 | |
// This code works properly | |
header( 'Content-Encoding: gzip' ); | |
echo gzencode('hello'); | |
// Example 4 | |
// And this works alright too: | |
echo gzdecode(gzencode('hello')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment