ID: 41831 Updated by: [EMAIL PROTECTED] Reported By: bennovandenberg at gmail dot com -Status: Open +Status: Assigned Bug Type: PDO related Operating System: FreeBSD 6.2 PHP Version: 5.2.3 -Assigned To: +Assigned To: iliaa
Previous Comments: ------------------------------------------------------------------------ [2007-06-29 15:17:13] bennovandenberg at gmail dot com The site works fine here, but here it is a slightly SHORTER and COMPLETE version... <?php $pdo = new PDO("sqlite:/somedatabase.sq3"); $imagelocation = "/someimage"; // or any other file $pdo->exec("CREATE TABLE Images (id INTEGER PRIMARY KEY AUTOINCREMENT, filename VARCHAR(50), image_data LONGBLOB)" ); $filename = "test"; $imagehandle = fopen($imagelocation, 'r'); if (is_resource($imagehandle)) echo "It's a resource!<br />"; else echo "It's not a resource<br />"; $stmt = $pdo->prepare("INSERT INTO Images (filename, image_data) VALUES (?,?);"); $stmt->bindParam(1, $filename); $stmt->bindParam(2, $imagehandle, PDO::PARAM_LOB); $stmt->execute(); if (is_resource($imagehandle)) echo "It's a resource!<br />"; else echo "It's not a resource<br />"; ?> ------------------------------------------------------------------------ [2007-06-29 12:09:01] [EMAIL PROTECTED] The server is not available. Please try to make a SHORT but COMPLETE reproduce case, so that there would be no need to put it somewhere. ------------------------------------------------------------------------ [2007-06-28 12:57:53] bennovandenberg at gmail dot com I've created a complete script to demonstrate the bug. It's too big to upload here, so I've uploaded it to my own webserver. The only things that need to be changed are the database in use, the settings for the database and a location of a image (any file will do actually). Also if a other database then mysql or sqlite are used, then $auto needs to be updated to include the auto increment keyword (mysql and sqlite use different ones). The url: http://develop.hatchan.nl/misc/bugs/php/pdo_sqlite/resource.phps With sqlite Outcome expected is: It's a resource! It's a resource! Actual result: It's a resource! It's not a resource ------------------------------------------------------------------------ [2007-06-27 21:27:22] [EMAIL PROTECTED] Thank you for this bug report. To properly diagnose the problem, we need a short but complete example script to be able to reproduce this bug ourselves. A proper reproducing script starts with <?php and ends with ?>, is max. 10-20 lines long and does not require any external resources such as databases, etc. If the script requires a database to demonstrate the issue, please make sure it creates all necessary tables, stored procedures etc. Please avoid embedding huge scripts into the report. ------------------------------------------------------------------------ [2007-06-27 21:18:59] bennovandenberg at gmail dot com Description: ------------ pdo_sqlite replaces a resource variable with the content of the file as text. This happens after the execute command. I tried the same with mysql, but with pdo_mysql it still stays a resource. So I guess the problem is with pdo_sqlite. (or its normal behavior to change the resource to text, but then pdo_mysql is wrong) Reproduce code: --------------- $pdo = new PDO("sqlite:/somepath/mydb.sq3"); $filename = "test"; $imagehandle = fopen($imagelocation, 'r'); // is_resource($imagehandle) == true $stmt = $pdo->prepare("INSERT INTO Images (filename, image_data) VALUES (?,?);"); $stmt->bindParam(1, $filename); $stmt->bindParam(2, $imagehandle, PDO::PARAM_LOB); $stmt->execute(); // is_resource($imagehandle) == false Expected result: ---------------- After the execute() I espect the $imagehandle to still be a resource. Actual result: -------------- $imagehandle has become a string with the content of the image. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=41831&edit=1