Take the State of PHP 2026 Survey →

Implement SQLite "openBlob" in PDO View as Markdown

Declined
Authors
bohwaz
Date
2017-09-19
Version
0.1
Source
wiki.php.net/rfc/implement_sqlite_openblob_in_pdo

Vote

Implement sqliteOpenBlob in PDO? closed
Yes
7
No
7
14 voters
adambaratz Yes 2017-10-10 13:28
ashnazg No 2017-10-11 13:18
bukka No 2017-10-14 07:16
danack No 2017-10-11 23:05
daverandom No 2017-10-28 08:28
galvao Yes 2017-10-14 14:29
kalle Yes 2017-10-11 21:08
kelunik No 2017-10-14 17:08
mariano Yes 2017-10-19 04:04
mbeccati Yes 2017-10-12 06:07
ocramius No 2017-10-09 23:13
peehaa No 2017-10-19 14:54
salathe Yes 2017-10-21 11:32
yunosh Yes 2017-10-12 07:51

Discussions on the mailing list

Matching PDO_SQLite features with SQLite3 extension
by BohwaZ/PHP · 15 messages
[RFC] [Discussion] Implement SQLite "openBlob" feature in PDO
by BohwaZ/PHP · 20 messages
[RFC] [VOTE] Implement missing SQLite feature "openBlob" in PDO
by BohwaZ/PHP · 18 messages
The future of SQLite3 and PDO/SQLite extensions
by BohwaZ · 2 messages

RFC text

Copied from wiki.php.net, last synchronized Oct 13, 2026 11:52 UTC

Introduction

The “SQLite” driver of PDO is missing some features provided by the “SQLite3” extension, namely “openBlob” which allows to access a stored blob as a stream/file pointer.

Proposal

As discussed on internals the SQLite driver of PDO is missing some features that are present in the SQLite3 extension.

One of those features has already been proposed and merged: Add support for SQLite open flags.

A second one has been proposed and is awaiting merging: Implement sqlite_stmt_readonly in PDO

But we are still missing this feature: SQLite3::openBlob: opening blobs for reading and writing as streams.

This would be implemented following the current practice of adding a driver-specific method:

PDO::sqliteOpenBlob(string $table , string $column , int $rowid [, string $dbname = “main” [, int $flags = PDO::SQLITE_OPEN_READONLY ]] )

This would return a resource file pointer. This would match exactly the behaviour of SQLite3::openBlob.

This is following what already exists in PDO, examples:

These driver-specific methods are only defined when instantiating PDO with the right driver, trying to call them with another driver results in an error due to calling an undefined method.

Why not just use PDO LOBs support via PDO::bindColumn and PDO::bindParam?

For reference: http://www.php.net/manual/en/pdo.lobs.php

As this was discussed on internals, the PDO LOB support is for accessing LOB using SQL queries, openBlob is for accessing LOBs directly. This is a very fast and efficient way of using SQLite as a blob store, which can't be done if going through SQL queries as traditional PDO::PARAM_LOB support is doing. Furthermore, openBlob allows to both read and write in a blob at the same time. And finally the current code handling LOBs in PDO via bindParam and bindColumn is broken, it is returning a string (with MySQL and SQLite, but not PostgreSQL) instead of a resource file pointer. I will try to spend time fixing that in the coming months.

In conclusion this new method and the existing PDO LOB support provide different features for different needs, and both are useful.

Backward Incompatible Changes

None.

Proposed PHP Version(s)

PHP 7.3

RFC Impact

To SAPIs

None.

To Existing Extensions

None.

To Opcache

None.

New Constants

None.

php.ini Defaults

None.

Open Issues

None so far.

Unaffected PHP Functionality

Nothing else is affected.

Future Scope

Any proposal to review and change current style and behaviour of driver-specific methods in PDO. This is out of the scope of this proposal.

Proposed Voting Choices

This proposal requires a 50%+1 majority. Vote closing on Oct 27, 2017.

Vote: Implement sqliteOpenBlob in PDO? — Yes: 7 · No: 7 (closed)

Patches and Tests

Patch: https://github.com/php/php-src/pull/2698

Implementation

After the project is implemented, this section should contain

  1. the version(s) it was merged to
  2. a link to the git commit(s)
  3. a link to the PHP manual entry for the feature
  4. a link to the language specification section (if any)

References

Rejected Features

Keep this updated with features that were discussed on the mail lists.