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

method_exists(PDO_sqlsrv) throws exception #1306

Closed
GDmac opened this issue Sep 21, 2021 · 4 comments
Closed

method_exists(PDO_sqlsrv) throws exception #1306

GDmac opened this issue Sep 21, 2021 · 4 comments

Comments

@GDmac
Copy link

GDmac commented Sep 21, 2021

MacOS (Mojave)
PHP 7.4.x
ODBC 17.8.1.1
pdo_sqlsrv 5.9.0

Problem description

When trying to check if a method_exists on the PDO (sqlsrv) driver,
it should not throw an exception.

        $connSqlite = new PDO("sqlite::memory:");
        $connSqlite->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        var_dump(method_exists($connSqlite, 'exec'));
        // true
        var_dump(method_exists($connSqlite, 'executeStatement'));
        // false

        $connSqlServer = new PDO("sqlsrv:server=$server ; Database=$database", $username, $password);
        $connSqlServer->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        var_dump(method_exists($connSqlServer, 'exec'));
        // true
        var_dump(method_exists($connSqlServer, 'executeStatement'));
        // Expected: false
        // Actual: PDOException : SQLSTATE[IMSSP]: This function is not implemented by this driver.
@yitam
Copy link
Contributor

yitam commented Sep 21, 2021

Hi @GDmac

I think this is related to #1258 , which is already fixed in 5.10.0-beta1. Please check.

@GDmac
Copy link
Author

GDmac commented Sep 22, 2021

yes, 5.10-beta fixes this,
when is 5.10 expected to be released?

@yitam
Copy link
Contributor

yitam commented Sep 22, 2021

Hi @GDmac PHP drivers for SQL Server, version 5.10, are targeted to be released right after the next release of Microsoft ODBC Driver in early 2022. Please stay tuned.

@yitam
Copy link
Contributor

yitam commented Sep 29, 2021

Closing this issue as it's a duplicate.

@yitam yitam closed this as completed Sep 29, 2021
GDmac added a commit to GDmac/symfony that referenced this issue Oct 5, 2021
pdo_sqlsrv driver 5.9.0 throws an exception for any call on method_exists().
(see microsoft/msphpsql/issues/1306)
executeStatement() is a DBAL-method, exec() is PDO.
fix by excluding method_exists() check on PDO type of connections
GDmac added a commit to GDmac/symfony that referenced this issue Oct 5, 2021
pdo_sqlsrv driver 5.9.0 throws an exception for any call on method_exists().
(see microsoft/msphpsql/issues/1306)
executeStatement() is a DBAL-method, exec() is PDO.
fix by excluding method_exists() check on PDO type of connections
derrabus added a commit to symfony/symfony that referenced this issue Oct 5, 2021
This PR was merged into the 4.4 branch.

Discussion
----------

[Cache][Lock] fix SQLSRV throws for method_exists()

pdo_sqlsrv driver 5.9.0 always throws an exception for any call on method_exists().
(see microsoft/msphpsql/issues/1306)

```executeStatement()``` is a DBAL-method, and ```exec()``` is PDO.
fix by excluding method_exists() on PDO type of connections

| Q             | A
| ------------- | ---
| Branch?       |  4.4 (and later)
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| License       | MIT

Commits
-------

d65f9ee fix SQLSRV throws for method_exists()
symfony-splitter pushed a commit to symfony/cache that referenced this issue Oct 5, 2021
pdo_sqlsrv driver 5.9.0 throws an exception for any call on method_exists().
(see microsoft/msphpsql/issues/1306)
executeStatement() is a DBAL-method, exec() is PDO.
fix by excluding method_exists() check on PDO type of connections
symfony-splitter pushed a commit to symfony/lock that referenced this issue Oct 5, 2021
pdo_sqlsrv driver 5.9.0 throws an exception for any call on method_exists().
(see microsoft/msphpsql/issues/1306)
executeStatement() is a DBAL-method, exec() is PDO.
fix by excluding method_exists() check on PDO type of connections
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants