PHP: rfc:implement_sqlite_openblob_in_pdo
source link: https://wiki.php.net/rfc/implement_sqlite_openblob_in_pdo
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
PHP RFC: Implement missing SQLite feature "openBlob" in PDO
- Version: 0.1
- Date: 2017-09-19
- Author: bohwaz
- Status: Declined
- First Published at: http://wiki.php.net/rfc/implement_sqlite_openblob_in_pdo
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:
- Creating a LOB (Large Object) in PostgreSQL: PDO::pgsqlLOBCreate
- Creating a function in SQLite: PDO::sqliteCreateFunction
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.
Implement sqliteOpenBlob in PDO? | ||
---|---|---|
Real name | Yes | No |
adambaratz (adambaratz) | ||
ashnazg (ashnazg) | ||
bukka (bukka) | ||
danack (danack) | ||
daverandom (daverandom) | ||
galvao (galvao) | ||
kalle (kalle) | ||
kelunik (kelunik) | ||
mariano (mariano) | ||
mbeccati (mbeccati) | ||
ocramius (ocramius) | ||
peehaa (peehaa) | ||
salathe (salathe) | ||
yunosh (yunosh) | ||
Final result: | 7 | 7 |
This poll has been closed. |
Patches and Tests
Implementation
After the project is implemented, this section should contain
- the version(s) it was merged to
- a link to the git commit(s)
- a link to the PHP manual entry for the feature
- a link to the language specification section (if any)
References
Rejected Features
Keep this updated with features that were discussed on the mail lists.
Recommend
-
278
PHP RFC: Generic Types and Functions Version: 0.4.0 Date: 2016-01-06 Author: Ben Scholzen 'DASPRiD'
-
173
PHP RFC: PCRE2 migration Version: 0.9 Date: 2017-10-16
-
138
PHP RFC: Allow explicit call-site pass-by-reference annotation Date: 2017-12-02 Author: Nikita Popov
-
34
Multiple PDO database connectionsDaniel's Dev Blog Developer, Trainer, Open Source Contributor Blog About me
-
6
Constructing objects with PDO Jan 5, 2017 • Marco Perone One of the most common non-trivial issue that needs to be solved in a project is deciding how to build domain objects starting from database data.
-
2
php5.3.8中编译pdo_mysql的艰难历程 – CFC4N的博客我们的一个项目,用了PDO_MYSQL拓展,准备迁移服务器,新环境需要编译安装环境。昨天,运维同事抽空编译了一下,一直编译不上pdo_mysql,同时,公司的一...
-
3
PHP PDO and mysql can not select the ID with letters advertisements in phpMyAdmin the query SELECT id FROM `column` WHERE `id`...
-
3
Rob Hedgpeth Posted on Feb 1...
-
0
PDO (PHP Data Objects)
-
1
[RFC] [Discussion] Implement SQLite "openBlob" feature in PDO Kia ora, following my...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK