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

Model.php Return Type Object causes Error when Saving. (Fixed with this modification) #329

Closed
timothymarois opened this issue Dec 18, 2016 · 1 comment

Comments

@timothymarois
Copy link
Contributor

timothymarois commented Dec 18, 2016

Currently if you use your models to return data types of object instead of array, you will be hit with an error once you try to use the save() method.

When checking if its an object is_object, its looking for a non-stdClas. To resolve these in model.php you need to remove all the !

if (is_object($data) && ! $data instanceof \stdClass)
{
     $data = $this->classToArray($data);
}

Corrected by:

if (is_object($data) && $data instanceof \stdClass)
{
     $data = $this->classToArray($data);
}

Otherwise you end up with Cannot use object of type stdClass as array This needs to be fixed on the save() , insert() , and update() methods.

@timothymarois
Copy link
Contributor Author

Looks like it needs to be updated on the update() method, not on the save() method otherwise it causes it to create new entries in the database. I haven't tested on insert() yet, but just so you're aware that it causes an error because it still thinks its an array.

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