Sorry, lost the n: EmbedMany.
I don't use github. The code is just an short example to demonstrate
my problem.
The defined array_key won't get used by doctrine/symfony2 for mongodb.
Hope the example is clear enough...
On 21 Jun., 18:00, Luis Cordova wrote:
> EmbedMay? not clear, please if you have url on github provide it
> sounds interesting about day times and cache
>
>
>
>
>
>
>
> On Tue, Jun 21, 2011 at 9:45 AM, Mathias wrote:
> > For example these Documents:
>
> >
> > class LocationCache
> > {
> > /**
> > * @var array
> > * @ODM\EmbedMany(targetDocument="test\TestBundle\Document
> > \LocationCacheDays")
> > */
> > protected $days = array();
>
> > /**
> > * @param LocationCacheDays
> > */
> > public function setDays(LocationCacheDays $days)
> > {
> > $day = $days->getDay();
> > $this->days = array_fill($day, 1, $days);
> > // or: $this->days[$day] = $days;
> > // will create the same resulting document
> > }
>
> > /**
> > * @return array
> > */
> > public function getDays()
> > {
> > return $this->days;
> > }
>
> > }
>
> > /**
> > * @ODM\EmbeddedDocument
> > */
> > class LocationCacheDays
> > {
> > /**
> > * @ODM\Int
> > */
> > protected $day;
>
> > // Setter
>
> > /**
> > * @param int
> > */
> > public function setDay($day)
> > {
> > $this->day = $day;
> > }
>
> > // Getter
>
> > /**
> > * @return int
> > */
> > public function getDay()
> > {
> > return $this->day;
> > }
> > }
> >
>
> > Here an example controller.
> >
> > $locationCache = new LocationCache();
> > $locationCacheDay = new LocationCacheDays();
> > $locationCacheDay->setDay(10);
> > $locationCache->setDays($locationCacheDay);
> > $dm->persist($locationCache);
> >
>
> > The expacted Document should look like this:
> >
> > Array
> > (
> > [_id] => 4e00aa161c911abd4e01
> > [days] => Array
> > (
> > [10] => Array
> > (
> > [day] => 10
> > )
>
> > )
>
> > )
> >
>
> > but it will result in:
> >
> > Array
> > (
> > [_id] => 4e00aa161c911abd4e01
> > [days] => Array
> > (
> > [0] => Array
> > (
> > [day] => 10
> > )
>
> > )
>
> > )
> >
>
> > Is there a way to predefine the array_key in an EmbedMay-Document?
>
> > Thanks in advance
>
> > --
> > If you want to report a vulnerability issue on symfony, please send it to
> > security at symfony-project.com
>
> > You received this message because you are subscribed to the Google
> > Groups "symfony users" group.
> > To post to this group, send email to symfony-users@googlegroups.com
> > To unsubscribe from this group, send email to
> > symfony-users+unsubscr...@googlegroups.com
> > For more options, visit this group at
> >http://groups.google.com/group/symfony-users?hl=en
--
If you want to report a vulnerability issue on symfony, please send it to
security at symfony-project.com
You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en