#44629 [Opn->Csd]: SQLite3 strings don't accept \0 while PHP ones do it
| From: | vrana@php.net | Date: | Fri, 07 Nov 2008 10:08:42 +0000 |
| Subject: | #44629 [Opn->Csd]: SQLite3 strings don't accept \0 while PHP ones do it | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-1410@lists.php.net to get a copy of this message | ||
ID: 44629
Updated by: vrana@php.net
Reported By: lapo at lapo dot it
-Status: Open
+Status: Closed
Bug Type: Documentation problem
Operating System: *
PHP Version: 5.2.5
New Comment:
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.
Thank you for the report, and for helping us make our documentation
better.
"PDO_SQLITE allows using strings apart from streams together with
PDO::PARAM_LOB."
Previous Comments:
------------------------------------------------------------------------
[2008-04-05 10:13:33] lapo at lapo dot it
If PDO_PARAM_LOB accepts a string then this bug is not valid, but OTOH
it could be changed to a documentation bug probably.
IMHO "PDO::PARAM_LOB tells PDO to map the data as a stream, so that you
can manipulate it using the PHP Streams API." doesn't express very
clearly the idea that "also a normal string can do".
------------------------------------------------------------------------
[2008-04-03 14:39:23] scottmac@php.net
PDO_PARAM_LOB accepts a resource or a string.
Not sure why another type is needed, though the fix is only in 5.3+.
------------------------------------------------------------------------
[2008-04-03 14:13:31] lapo at lapo dot it
Description:
------------
While PHP strings support \0s in them, SQLite3 doesn't accept them in
text fields, only in blob fields.
A possible work-around, thanks to the closed bug #41135, is to write to
a memory stream and use PDO::PARAM_LOB, but that seems a bit overkill
for very small "string" values such as the binary form of PHP's sha1().
I think the best solution could be to scan a PDO::PARAM_STR value for
zeros and in that case use sqlite3_bind_blob just as if it was a
PDO::PARAM_LOB.
Or maybe (a little cleaner) create a (non-large) PDO::PARAM_BINARY.
Using streams is certainly the best approach for LOB, but I think it's
overkill for non-large-OBs.
Tell me what of the two solutions the PHP team would prefer to adopt
and I can eventually produce a patch.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=44629&edit=1