I go MSSQL databse which contains attachments – most of them are PDFs. I want to create simple website, that will display attachement after clicking a button. I got main website preared (there are records with attachments’ titles and a link fo the other page, that is supposed to just show the attachment in the new tab).
I’ve been using PDO as I heard that is secure and pretty simple.
My query ‘$sql’ for sure returns one row (I have checked that by simpby doing var_dump of the FetchAll()).
` $stmt = $pdo->prepare($sql);
$stmt->execute([$id]);
$stmt->bindColumn(10,$lob, PDO::PARAM_LOB);
$stmt->bindColumn(11, $attachment, PDO::PARAM_STR, 256);
$stmt->fetch(PDO::FETCH_BOUND);
$lobContent = stream_get_contents($lob);
$ext = substr(strrchr($attachment, '.'),1);
header("Content-Type: Application/pdf");
// fpassthru($lob) shows some weird stuff that looks like memory leak
echo $lobContent; `
Any ideas what Am I doing wrong here? If I try to use fpassthru() it show me some garbage, I mean it looks like memory leak or something, there are some parts of the code, that is not on my website and is not in the database…
I have checked if the query result isnt empty, tried to just fetchAll() the data I got but as told above, got very unexpected bahviour.