According to this thread I should use fopen
. I have done this but in my example I'm using bindValue
instead of bindParam
.
$query->bindValue(':'.$key, fopen($value, "rb"), PDO::PARAM_LOB);
$value
contains the path to the file (/var/www/html/....jpg).
I tried this but when I open SQLiteManager with the specific entry I get [Exception ... "Component returened failure code 0x8052000b (NS_ERROR_FILE_CORRUPTED)
.
Why doesn't this work?
This is how the rest of my implementation looks like.
Edit:
file_get_contents
brings me the same error.
Perhaps it is a problem with the php modules?
SELECT sqlite_version()
brings me 3.7.7.1
phpinfo()
gives me
Configure Command: '--without-sqlite'
additional .ini files parsed: /etc/php.d/pdo_sqlite.ini, /etc/php.d/sqlite.ini
SQLite:
PECL Module version 2.0-dev $Id: sqlite.c,v 1.166.2.13.2.9 2007/05/19 17:58:22 iliaa Exp $
SQLite Library 2.8.17
SQLite Encoding UTF-8
PDO drivers mysql, odbc, sqlite, sqlite2
pdo_sqlite
PECL Module version 1.0.1 $Id: pdo_sqlite.c,v 1.10.2.6.2.2 2007/03/23 14:30:00 wez Exp $
SQLite Library 3.3.6
PDO:
PDO drivers mysql, odbc, sqlite, sqlite2
Edit 2:
This is how I can display the BLOB images. getimage.php
header("Content-type: image/jpg");
require_once('class.DatabaseQuery.php');
$db = new DatabaseQuery();
$name = sqlite_escape_string($_GET['name']);
$sql = "SELECT image FROM $name WHERE _id=:id;";
$id = $_GET['id'];
$result = $db->ExecuteQuery($sql, array("id"=>$id));
echo $result[0]['image'];
Display images: <img src='getimage.php?name=$printname&id=" . $row['_id'] . "' heigth='75' width='75' alt='Test' />
So I can display the images. But how can I insert an image in the database?