Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DBAL-1156: Doctrine assumes that PDO is available #1097

Closed
doctrinebot opened this issue Feb 23, 2015 · 12 comments
Closed

DBAL-1156: Doctrine assumes that PDO is available #1097

doctrinebot opened this issue Feb 23, 2015 · 12 comments
Assignees
Labels
Milestone

Comments

@doctrinebot
Copy link

Jira issue originally created by user azielinski:

use PDO and references to PDO class are seen in following files:
Connection.php
Statement.php
Cache/ArrayStatement.php
Cache/ResultCacheStatement.php
Driver/PDOConnection.php
Driver/Mysqli/MysqliStatement.php
Driver/OCI8/OCI8Statement.php
Driver/SQLSrv/SQLSrvStatement.php
Driver/Portability/Statement.php

It's all about using constants like PDO::FETCH_COLUMN. No actual methods are invoked, no objects are instantiated. This could be easily abstracted out to a class included in doctrine-dbal.

I stumbled upon this because I tried to use mysqli driver specifically because my installation of PHP is compiled with --disable-pdo.

As a quick & dirty workaround I included a file PDO.php with a shim, but it would be nice if Doctrine did not assume PDO is installed.

I am more than happy to prepare a pull request to fix it if you confirm this is something that needs attention.

@doctrinebot
Copy link
Author

Comment created by @Ocramius:

Seems rather like a missing dependency in composer.json to me: we rely on PDO's APIs, and we're not really interested in polyfilling it when it's not available, as it's actually a lot of code to write for a little achievement :-\

@doctrinebot
Copy link
Author

Comment created by azielinski:

Why provide non-PDO drivers then? In doctrine-dbal not a single method or object from PDO is used (aside of PDOConnection.php), it's all about accessing constants like PDO::PARAM_STR. This particular thing could be polyfilled very easily.

@doctrinebot
Copy link
Author

Comment created by @Ocramius:

Those drivers work as long as PDO is also installed.

@doctrinebot
Copy link
Author

Comment created by azielinski:

Sure they do, my point is that with minimal effort (that I offer to provide) those drivers could work without PDO as well. In fact that would make more sense - I can imagine that one of typical use cases for e.g. Mysqli driver is a situation where PDO cannot be used for some reason.

Correct me if I'm wrong, but I believe there is no real reason for doctrine-dbal to depend on PDO. Aside of accessing constants, PDO is only used by PDOConnection (which is only used by PDO-based drivers). PDO constants can be shimmed extremely easily.

@doctrinebot
Copy link
Author

Comment created by @Ocramius:

[~azielinski] if that's the minimal requirement, then a shim is fine

@chrisguitarguy
Copy link
Contributor

Seems rather like a missing dependency in composer.json to me

I suspect this one can be closed as composer.json requires PDO explicitly now.

@lcobucci lcobucci assigned lcobucci and unassigned beberlei Nov 19, 2017
@lcobucci lcobucci added this to the 2.6.0 milestone Nov 19, 2017
@lcobucci
Copy link
Member

@chrisguitarguy thanks!

@lcobucci
Copy link
Member

Fixed in #2709

@morozov
Copy link
Member

morozov commented Nov 19, 2017

This is a thing I still don't understand about the DBAL: as a user, why in order to use oci8 or ibm_db2 I should also install PDO? I understand that for some reason the DBAL it uses its contstants as part of its API but it looks like a design issue.

Would the community consider a patch which replaces the usage of PDO constants with its own ones?

@lcobucci
Copy link
Member

@morozov we had that discussion already, right? maybe we can review this for v3.0?

@morozov
Copy link
Member

morozov commented Nov 19, 2017

@lcobucci #808 (comment) is the only discussion I'm aware of. The patch wasn't about fixing the real issue. v3.0 sounds reasonable to me.

@github-actions
Copy link

github-actions bot commented Aug 3, 2022

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 3, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants