pdo_sqlite changes resource to text
| Bug #41831 | pdo_sqlite changes resource to text | ||||
|---|---|---|---|---|---|
| Submitted: | 2007-06-27 21:18 UTC | Modified: | 2007-08-01 22:45 UTC | ||
| From: | bennovandenberg at gmail dot com | Assigned: | iliaa (profile) | ||
| Status: | Closed | Package: | PDO related | ||
| PHP Version: | 5.2.3 | OS: | FreeBSD 6.2 | ||
| Private report: | No | CVE-ID: | None | ||
[2007-06-27 21:18 UTC] 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.
Patches
Pull Requests
History
AllCommentsChangesGit/SVN commits
[2007-06-27 21:27 UTC] tony2001@php.net
[2007-06-28 12:57 UTC] bennovandenberg at gmail dot com
[2007-06-29 12:09 UTC] tony2001@php.net
[2007-06-29 15:17 UTC] 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-08-01 22:45 UTC] iliaa@php.net