associated with the respective parent, using a multidimensional array?
I have a data array structured like this (generated from a flat file):
[User] => array (
[name] => John
)
[Todo] => array (
[0] => array (
[type] => single
[note] => bread, milk, coffee
)
[1] => array (
[type] => multiple
[TodoChild] => array (
[0] => array (
[type] => single
[note] => cereal
)
[1] => array (
[type] => single
[note] => dessert
)
)
)
)
Todo actsAs "Tree" and has both a hasMany and belongsTo relationship
to itself (both relationships only have the foreignKey set to
"parent_id"). The model works fine when the user is adding children
via the webpage, but I want to find the quickest and easiest way to do
this manually or "programmatically" without having to resort to a ton
of code just to do this seemingly simple task.
The only way I thought of to accomplish this was to use a recursive
method that would save the parent, get its generated ID and set it as
the "parent_id" field for each child and then save each child.
However, that seemed a bit much just to simply add children to a
parent manually.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---
No comments:
Post a Comment