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

BUG: DataObject::__construct() now accepts stdClass for $record #917

Merged

Conversation

TheFrozenFire
Copy link
Contributor

DataObject::__construct() currently only accepts an array. This works fine the majority of the time, but a minor enhancement is to allow stdClass to be accepted as well.

The reason for this is that PDO results are often fetched as objects when doing database migrations, so being able to create new DataObjects directly from the results of a PDO statement fetch is very useful.

There should be no side-effects from this, as the additional acceptance is limited to stdClass, which is only produced in cases where an anonymous object is constructed, usually from a typecast to an object, but in certain other cases as well, such as PDOStatement::fetch(PDO::FETCH_OBJ).

@simonwelsh
Copy link
Contributor

Looks good to me.

simonwelsh added a commit that referenced this pull request Nov 3, 2012
…lass

API: DataObject::__construct() now accepts stdClass for $record
@simonwelsh simonwelsh merged commit d8c9202 into silverstripe:master Nov 3, 2012
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.

None yet

2 participants