We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Problem saving relational data

Hello guys!

I'm making a web-app which has almost 50 tables in the database with a lot of relations...

Would be very long to put here all the "schema" of my project.

I have got this error:

Only objects can be stored as part of belongs-to relations

when run save() method in this line if ($some_data->save() === false) {

$some_data is an Object (a big one).

If I run var_dump($some_data); with xdebug This will the first line:

object(SomeData)[64]

Could be the way that I map the ORM? How can I debug this kind of issues? Which are the reasons of this error? I really don't know where to search the issue :-(



85.5k

just guessing ... $record->my_relation_data = $rec->toArray();

it seems like you are trying to put a huge object into a relation data



13.8k

Hi @Izo, thanks for reply!

For $record did you mean the very last one? Why my_relation_data is not on CamelCase? And why need to be an array?

Actually is it an object.

just guessing ... $record->my_relation_data = $rec->toArray();

it seems like you are trying to put a huge object into a relation data



13.8k

I found that some of the variables are arrays instead of objects! I have casted it to objects, now the error Only objects can be stored as part of belongs-to relations is gone!

But I have got this error:

some_col is required

How can I get more information, because... Let's say I have some_col in many tables...

How much of Related objects you are trying to save in one time?



13.8k

Hi Karolis!

Why? is there any limitation about the number on relational objects in Phalcon?

I think almost 10 tables will be affected by the INSERT.

How much of Related objects you are trying to save in one time?