On 3 Oct 2012, at 9:33am, Tim Streater <t...@clothears.org.uk> wrote:

> I've got a temporary database with a blob column. I'm using the PHP PDO 
> interface, and I'd like to store some binary data into the blob; it's 
> actually an image. Later I'm going to read it back and write it to disk. 
> What's the right way to get the data into the column? At the moment I'm using 
> str_replace to change any single-quote to two single-quotes, and then doing 
> as follows:
> 
>  $dbh->query ("update imagetable set imagedata='" . $bd . "' where linkid=" . 
> $linkid);
> 
> but this is giving me:
> 
>  SQLite error: general code: HY000 error: 1, unrecognized token: "'����/�Exif"
> 
> Seems to me my approach is wrong.

I believe that BLOBs can't be handled as strings.  You will need to use

http://www.php.net/manual/en/pdostatement.bindvalue.php

OR

http://www.php.net/manual/en/pdostatement.bindparam.php

Unfortunately I cannot give detailed instructions since I use the SQLite3 
interface for PHP rather than the PDO one.

Simon.
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to