php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #44629 SQLite3 strings don't accept \0 while PHP ones do it
Submitted: 2008-04-03 14:13 UTC Modified: 2008-11-07 10:08 UTC
From: lapo at lapo dot it Assigned:
Status: Closed Package: Documentation problem
PHP Version: 5.2.5 OS: *
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: lapo at lapo dot it
New email:
PHP Version: OS:

 

 [2008-04-03 14:13 UTC] 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.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-04-03 14:39 UTC] 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-05 10:13 UTC] 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-11-07 10:08 UTC] vrana@php.net
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."
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri Dec 12 06:00:01 2025 UTC