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

Utilities::stringToNumeric throws Exception with SQLite driver #289

Open
mazinsw opened this issue Apr 25, 2019 · 0 comments
Open

Utilities::stringToNumeric throws Exception with SQLite driver #289

mazinsw opened this issue Apr 25, 2019 · 0 comments

Comments

@mazinsw
Copy link

mazinsw commented Apr 25, 2019

The column loop try to access nonexistent column, other driver like MySQL return false, but SQLite driver has a different behavior and throws a PDOException when $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); is set.

I suggest to use columnCount() from PDOStatement to avoid accessing invalid column index.

Sample code:

$columnCount = $statement->columnCount();
for ($i = 0; $i < $columnCount && ($columnMeta = $statement->getColumnMeta($i)) !== false; $i++) {

Because getColumnMeta are not supported by all driver it's return must always be checked

I am current using legacy branch it would be great if patches apply on it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant