Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
predefine key for EmbedMany
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Mathias  
View profile  
 More options Jun 21 2011, 10:45 am
From: Mathias <m.rohnst...@googlemail.com>
Date: Tue, 21 Jun 2011 07:45:04 -0700 (PDT)
Local: Tues, Jun 21 2011 10:45 am
Subject: [Sf2+MongoDB] predefine key for EmbedMany
For example these Documents:

<pre>
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;
     }

}

</pre>

Here an example controller.
<pre>
$locationCache = new LocationCache();
$locationCacheDay = new LocationCacheDays();
$locationCacheDay->setDay(10);
$locationCache->setDays($locationCacheDay);
$dm->persist($locationCache);
</pre>

The expacted Document should look like this:
<pre>
Array
(
    [_id] => 4e00aa161c911abd4e000001
    [days] => Array
        (
            [10] => Array
                (
                    [day] => 10
                )

        )

)
</pre>

but it will result in:
<pre>
Array
(
    [_id] => 4e00aa161c911abd4e000001
    [days] => Array
        (
            [0] => Array
                (
                    [day] => 10
                )

        )

)
</pre>

Is there a way to predefine the array_key in an EmbedMay-Document?

Thanks in advance


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Discussion subject changed to "[Sf2+MongoDB] predefine key for EmbedMany" by Luis Cordova
Luis Cordova  
View profile  
 More options Jun 21 2011, 12:00 pm
From: Luis Cordova <cordo...@gmail.com>
Date: Tue, 21 Jun 2011 11:00:03 -0500
Local: Tues, Jun 21 2011 12:00 pm
Subject: Re: [symfony-users] [Sf2+MongoDB] predefine key for EmbedMany
EmbedMay? not clear, please if you have url on github provide it
sounds interesting about day times and cache


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Discussion subject changed to "predefine key for EmbedMany" by Mathias
Mathias  
View profile  
 More options Jun 22 2011, 2:28 am
From: Mathias <m.rohnst...@googlemail.com>
Date: Tue, 21 Jun 2011 23:28:52 -0700 (PDT)
Local: Wed, Jun 22 2011 2:28 am
Subject: Re: [Sf2+MongoDB] predefine key for EmbedMany
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 <cordo...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
tecbot  
View profile  
 More options Dec 3 2011, 4:04 am
From: tecbot <thomas.a...@tecbot.de>
Date: Sat, 3 Dec 2011 01:04:58 -0800 (PST)
Local: Sat, Dec 3 2011 4:04 am
Subject: Re: [Sf2+MongoDB] predefine key for EmbedMany

Look at this pull request: https://github.com/doctrine/mongodb-odm/pull/194
It was merged yesterday, but the pull requests brokes the remove operation
of embedded documents.
Please wait


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »