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

storing related record

After hours of testing, I have the following assumption (conclusion) regarding creating a related record (if there is any mistake please point it out):

even it is a 1-to-1 situation, for one model ("Albums" in the example from the doc) to save, it has to be "belongsTo".


in the doc, it describes "belongsTo" as 1-to-many (only), perhaps it is a little bit misleading; and maybe it could be more clear if the doc explicitly tells which relationship definition is required to create related record?



33.8k

Yeah, because the existence of an album dependes of the existence of an artist. If it were in the opossite way, Albums will use hasOne.

But yeah, it doesn't make full sense. Maybe is a mistake of the docs.

@phalcon