Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8382903
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T17:02:14+00:00 2026-06-09T17:02:14+00:00

so i have a school, each school has multiple bell schedules and each schedule

  • 0

so i have a school, each school has multiple bell schedules and each schedule has details:

school (document)
-- bell schedule (embedded document)
---- bell schedule details (embedded document)

when i clone the school object and print_r the school, it comes back with the proper objects in the clone. however, when i try to persist the school, it doesn’t save the details properly. is there something that I need to do in order for this to work properly? is there a flag I need to set or something?

what im trying to do is:

$school2 = clone $school1;
$dm->persist($school2);
$dm->flush();

---- classes ----

    /**
     * @MongoDB\Document(collection="schools")
     */
    class School
    {   
        /**
         * @MongoDB\EmbedMany
         */
        protected $bell_schedules = array();

        public function addBellSchedules(BellSchedule $bellSchedules)
        {
            $this->bell_schedules[] = $bellSchedules;
        }

        public function getBellSchedules()
        {
            return $this->bell_schedules;
        }

        public function setBellSchedules(\Doctrine\Common\Collections\ArrayCollection $bell_schedules)
        {
            $this->bell_schedules = $bell_schedules;
            return $this;
        }
    }


    /**
     * @MongoDB\EmbeddedDocument
     */
    class BellSchedule
    {
        /**
         * @MongoDB\EmbedMany
         */
        private $bell_schedule_details

        public function getBellScheduleDetails()
        {
            return $this->bell_schedule_details;
        }

        public function setBellScheduleDetails(\Doctrine\Common\Collections\ArrayCollection $bell_schedule_details)
        {
            $this->bell_schedule_details = $bell_schedule_details;
            return $this;
        }
    }

    /**
     * @MongoDB\EmbeddedDocument
     */
    class BellScheduleDetail
    {    
        private $period;
        private $label;
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T17:02:17+00:00Added an answer on June 9, 2026 at 5:02 pm

    Your @EmbedMany annotations are missing the targetDocument attribute, which should correspond to the class name of the embedded object(s). See the annotation reference for more information. Also, you are missing field mappings for the BellScheduleDetail class. You may want to use @String for those fields.

    Lastly, I would advise initializing your EmbedMany and ReferenceMany fields as ArrayCollection instances rather than empty arrays. That way you can always expect the property to be a Collection implementation (either ArrayCollection or PersistentCollection). It may not make much difference in your case (using the [] operator), but it can come in handy if you find yourself doing other array operations on the property.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have a data model set up where each School object has a
I have two enums that cross reference each other. Each one has a constructor
I have a php page that has a few HTML questions on it, each
I have an application which communicates with a database. Each table has a unique
I'm a teacher at a school which has an SmartBoard interactive whiteboard in each
For example in classic object oriented programming I might have a class School which
I have a webapp where I'm created an embedded document for educations. The job
I'm creating for school a multiple choice program. For this I have to write
I have Group and each group has contacts associated with it. When a user
My school has entered into a Robotics Tournament that competes several schools against each

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.