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

SQL errors not thrown by PDOMySQL class #12

Closed
FaaPz opened this issue Jul 18, 2017 · 3 comments
Closed

SQL errors not thrown by PDOMySQL class #12

FaaPz opened this issue Jul 18, 2017 · 3 comments
Assignees
Milestone

Comments

@FaaPz
Copy link

FaaPz commented Jul 18, 2017

Several times my SQL queries (which are perfect thanks to Parable's query builder!) failed during execution. I've mistaken a unique index on one of my columns.

But... Parable never warned me! Database::query() simply returned false. Which is legit, according to the PHP docs here.

PDO errors are silenced by default when the occur (see PHP docs once more). Please, make them load with warnings or exceptions (by "Parable default")! 😄

@FaaPz
Copy link
Author

FaaPz commented Jul 18, 2017

Oh! I've forgot to mention that it's not possible to access PDO's errorCode() and errorInfo() methods in the Query and Repository classes. 😜

@devvoh
Copy link
Owner

devvoh commented Jul 18, 2017

You make a good point! In 0.12.5, you'll be able to do the following:

"database" => [
    "type" => \Parable\ORM\Database::TYPE_MYSQL,
    "location"  => "localhost",
    "username"  => "username",
    "password"  => "password",
    "database"  => "database",
    "errorMode" => \PDO::ERRMODE_EXCEPTION,
],

Default remains ERRMODE_SILENT, though. Like a debug setting, I'd say throwing database-related errors should be a conscious choice. Obviously, documentation is essential with stuff like this 🙂

@devvoh devvoh self-assigned this Jul 18, 2017
@devvoh devvoh added this to the 0.12.5 milestone Jul 18, 2017
devvoh added a commit that referenced this issue Jul 22, 2017
@devvoh
Copy link
Owner

devvoh commented Jul 22, 2017

Should be fixed in 0.12.5. Reopen if it requires fixes!

@devvoh devvoh closed this as completed Jul 22, 2017
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