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

Cannot serialize active record #267

Open
tehmaestro opened this issue Jul 18, 2023 · 0 comments
Open

Cannot serialize active record #267

tehmaestro opened this issue Jul 18, 2023 · 0 comments

Comments

@tehmaestro
Copy link

tehmaestro commented Jul 18, 2023

What steps will reproduce the problem?

$object = new ActiveRecordObject($mysqlDatabaseConnection);
serialize($object);

What is the expected result?

Serialize the object

What do you get instead?

Error

Serialization of 'Closure' is not allowed

Additional info

Q A
Version 1.0.?
PHP version 8.0
Operating system MacOS Docker

Hi. I'm trying to setup a new project using yii3. Actually, I'm trying to implement a caching mechanism similar to how

Yii::$app->db->cache(function() use ($query)  { return $query->one() } ...)

used to work in yii2 and I get this error. The Yii3 Redis cache handler is the one that serializes the value before saving into cache.
Is this expected? I guess it is because of the DB connection parameter?

Edit: Now I see that in yii2 only the raw results were cached, and then the models would be populated. Is there a better way other that creating an ActiveQuery and calling ->populate($rows)?

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