Skip to content

[5.2] Use proper PDO fetch style #3814

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

Closed
wants to merge 1 commit into from
Closed

Conversation

vlakoff
Copy link
Contributor

@vlakoff vlakoff commented Jun 18, 2016

PDO fetch style FETCH_CLASS is expected to be used along a class name.


It currently works in Laravel because the latter does the following, which happens to work only by chance:

$results = $stmt->fetchAll(PDO::FETCH_CLASS);


However, the following would produce an error:

$stmt->setFetchMode(PDO::FETCH_CLASS);
$results = $stmt->fetchAll();

PDOStatement::setFetchMode(): SQLSTATE[HY000]: General error: fetch mode requires the classname argument


This PR switches to the proper fetch style, which is robuster, and even more importantly, less confusing for the user. It's fully backward compatible.


Refs:

@GrahamCampbell
Copy link
Member

Thanks. Probably best to do this on develop.

vlakoff referenced this pull request in laravel/framework Jun 18, 2016
@taylorotwell
Copy link
Member

Yeah can we go ahead and send this to 5.3 when you get a chance just to be safe? Thanks

@GrahamCampbell
Copy link
Member

👍

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

Successfully merging this pull request may close these issues.

3 participants