SunshinePHP 2019 CFP Started

MySQL 改良版拡張モジュール

add a note add a note

User Contributed Notes 1 note

veit dot heise at heise-media dot eu
2 months ago
How to do?
I try to "shift" JPEG-files and RAW-files into a LONG_BLOB-field in my database. When I use following:

$db = ... connect to MYSQL-database;
$dir = opendir($specialdirectory);
$filename = readdir($dir);
$handle = fopen($specialdirectory.$filename);
$picture = stream_get_contents($handle);
$sql = "INSERT INTO table SET xyz=.... , picture=`".$picture."`";
if (!$res = $db->query($sql)) { error handling ....
// the field "picture" bounced against $picture

$dump = bin2hex($picture);
$sql = "INSERT INTO table SET xyz=...., picture=`".$picture."`";
// no error occurs.... but the content of the LONG_BLOB-field picture
// is not usable as a JPEG or RAW picture.... it is destroyed.

To Top