I have a database with a BLOB field (weeklyOccupancy). I am trying to access the data in PHP using:
$sqlCmd = 'select weeklyOccupancy from Occupancy order by startDate;';
$pdoStmt = $dbh->query($sqlCmd);
$pdoStmt->bindColumn(1, $lob, PDO::PARAM_LOB);
$pdoStmt->fetch(PDO::FETCH_BOUND);
foreach($pdoStmt as $row){
$weeklyData = stream_get_contents($lob);
....
}
However, stream_get_contents says that $lob is a string (named "Resource id #1) although I believe it should be a stream. I have seen this mentioned as a bug (http://www.php.net/manual/en/pdo.lobs.php#96311) but the workaround is not relevant for my application - in which the blob holds a bit string not an image to be displayed.
Any ideas how I can get the data out of a blob field in PHP? Thanks