Monday, April 25, 2011

saving HABTM data with constructing my own array data

I wanted to save a HABTM model but without using a regular form.
Consider
Entity1 HABTM Entity2, so we have a DB table for entity1, one for
entity2 and one like entity1_entity2.

I construct my own array like:
[Entity1] => (field1, field2)
[Entity2] => (
[0] => (field1, field2)
[1] => (field1, field2)
[2] => (field1, field2)
)

But entity1->saveAll() doesn't save the data. Do I have to insert to
my array the entity1_entity2 relation? Because when I do a find() in
entity1 I get an array like:

[Entity1] => (field1, field2)
[Entity2] => (
[0] => (field1, field2, [Entity1Entiry2]=>())
[1] => (field1, field2, [Entity1Entiry2]=>())
[2] => (field1, field2, [Entity1Entiry2]=>())
)

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


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

No comments: