On Thu, 10 Feb 2011 16:38:40 -0500, Stephan Beal <sgb...@googlemail.com>  
wrote:

> On Sun, Feb 6, 2011 at 2:36 PM, Samuel Adam <a...@certifound.com> wrote:
>
>>
>>        * Make sure the binding is done as BLOB and not TEXT.  PDO  
>> probably
>> has
>> its own flags defined for this.  This is the part that tells SQLite
>> whether you are inserting TEXT or BLOB.
>>
>
> http://www.php.net/manual/en/pdostatement.bindparam.php
>
> When inserting the GIF, the 3rd argument to bindParam() must be
> PDO::PARAM_LOB  (not BLOB, interestingly). The default is PDO::PARAM_STR,
> which almost certainly results in the OP's frustration.

Thanks for actually looking this up.  But on Sun, 06 Feb 2011 10:53:05  
-0500, Yves Goergen <nospam.l...@unclassified.de> actually said he was  
using “a PDO method to execute a prepared statement with an array of  
values to be used as parameters”.  That appears to be this:

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

        input_parameters
        
        An array of values with as many elements as there are bound
        parameters in the SQL statement being executed. All values are
        treated as PDO::PARAM_STR.

In other words, he is using a PHPism which hands off only one type and  
then blaming SQLite for treating his data as the wrong type.  (That  
interface is bizarre, by the way:  Either you can bind the parameters  
yourself and then call it with no arguments, or bind nothing yourself and  
pass it an array of values which will be treated as text.  Mr. Goergen  
appears to be doing the latter.)

Worse, PDO::PARAM_LOB is for binding a stream and not a regular variable:
http://www.php.net/manual/en/pdo.lobs.php
And it is for “objects [] either textual or binary in nature” (Id.).  As  
usual with PHP, the docs are very imprecise on what the database will  
actually get.  “Example #14[:] Inserting an image into a database” thereby  
(based on an fopen() stream) looks promising, but still does not document  
the type told to the database.  If there is a way anywhere in PDO to  
explicitly hand SQLite a BLOB type and/or so do from a variable, the PDO  
constants list
http://www.php.net/manual/en/pdo.constants.php
fails to disclose it.

PHP’s SQLite3 class does have a SQLITE3_BLOB flag.  But that is not what  
Mr. Goergen is using.

Easiest solution:  The UPDATE and triggers suggested on Mon, 07 Feb 2011  
03:16:54 -0500 by Philip Graham Willoughby  
<phil.willoug...@strawberrycat.com>.  Best solution:  Reading and  
understanding the docs, particularly as to SQLite’s type system, and then  
making a few thoughtful decisions as to architecture.

Very truly,

Samuel Adam ◊ <http://certifound.com/>
763 Montgomery Road ◊ Hillsborough, NJ  08844-1304 ◊ United States
Legal advice from a non-lawyer: “If you are sued, don’t do what the
Supreme Court of New Jersey, its agents, and its officers did.”
http://www.youtube.com/watch?v=iT2hEwBfU1g
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to