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

Relation with multiple fields

Hi All,

while using an array of fields (instead of the simple field) as described in "Working with Models" reference in a hasMany relation, i get a "Not Implemented Exception" while trying to set the related Object via relation alias.

It works fine in reading since i can count the elements, but i can't update the value of the relation.

A sample code here: Passenger table has a composite PK (PersonId, FlightId) so array of cols has been used in Passenger Model relation initialization for baggages (wich includes both Passenger pk cols).

$Passenger->Baggages = $passengerBags; //array of Baggages

This causes an exception with the message "Not Implemented". How can i deal with this? Is this a bug?

Thanks to all



20.4k
edited Feb '14

I suppose to have found the root of the problem. Looking for the message in the source of Phalcon, in the _postSaveRelatedRecords method (that is raising the exception) i've found these lines, that cause the problem!

            if (Z_TYPE_P(columns) == IS_ARRAY) { 
                phalcon_call_method_p1_key(NULL, connection, "rollback", nesting, 249905402621539599UL);
                PHALCON_THROW_EXCEPTION_STR(phalcon_mvc_model_exception_ce, "Not implemented");
                return;
            }

Arrays aren't supported yet i suppose... Please acknowledge.

I got the same exception when trying to update my model and while debugging came across the same chunk of code you pasted above. It definitely looks like composite foreign keys are not fully supported even though there is a way to establish that relationship in the model.



20.4k

Hi all, i'm upping this old post of mine... what's new about this in last release?