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 8183427
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T01:09:26+00:00 2026-06-07T01:09:26+00:00

he guys, i want to make a simple reference on mongodb documents using symfony2.

  • 0

he guys,

i want to make a simple reference on mongodb documents using symfony2.

i have this two documents and want to store picture references into the requests document. it works for me, if i have only the picture ids in the requests document.

so i need the follow:

can everyone change the document files and make and extends the custum call to get all pictures as object from the requests (picture array)?

my original files:

Document Pictures:

<?php

namespace TestBundle\Document;
use Doctrine\ODM\MongoDB\Mapping\Annotations as MongoDB;

/**
 * @MongoDB\Document(repositoryClass="TestBundle\Repository\RequestsRepository")
 */
class Requests
{
    /**
     * @MongoDB\Id
     */
    protected $id;

    /**
     * @MongoDB\String
     */
    protected $title;

    public function setId($id)
    {
        $this->id = $id;
    }

    public function getId()
    {
        return $this->id;
    }

    public function setTitle($title)
    {
        $this->title = $title;
    }

    public function getTitle()
    {
        return $this->title;
    }
}

Document Pictures:

<?php

namespace TestBundle\Document;
use Doctrine\ODM\MongoDB\Mapping\Annotations as MongoDB;

/**
 * @MongoDB\Document(repositoryClass="TestBundle\Repository\PicturesRepository")
 */
class Pictures
{
    /**
     * @MongoDB\Id
     */
    protected $id;

    /**
     * @MongoDB\String
     */
    protected $filename;

    public function setId($id)
    {
        $this->id = $id;
    }

    public function getId()
    {
        return $this->id;
    }

    public function setFilename($filename)
    {
        $this->filename = $filename;
    }

    public function getTitle()
    {
        return $this->filename;
    }
}

My Basic Calls:

$dm = $this->get('doctrine.odm.mongodb.document_manager');
$request = $dm->getRepository('TestBundle:Requests')->find($requestId);

To my tests:

i added in the requests document the follow:

/**
 * @MongoDB\ReferenceMany(targetDocument="Pictures",cascade={"persist"},simple="true")
 */
protected $pictures = array();
public function setPictures($pictures)
{
    $this->pictures[] = $pictures;
}

public function getPictures()
{
    return $this->pictures;

}

and added pictures like this:

$dm     = $this->get('doctrine.odm.mongodb.document_manager');
$photo   = $dm->getRepository('TestBundle:Pictures')->find($photoId);

$dm1 = $this->get('doctrine.odm.mongodb.document_manager');
$request = $dm1->getRepository('TestBundle:Requests')->find($requestId);

$request->setPictures($photo);
$dm1->flush();

this works – but i cannot get the pictures by loading the document.

my code to load:

$dm1 = $this->get('doctrine.odm.mongodb.document_manager');
$request = $dm1->getRepository('TestBundle:Requests')->find($requestId);

$pictures = $request->getPictures();

foreach($pictures as $picture)
{
    print $picture->getId();         
}

THIS WILL NOT WORK. i become the follow error:

Fatal error: Doctrine\ODM\MongoDB\Proxy\ProxyFactory::getProxy():
Failed opening required
‘…/app/cache/dev/doctrine/odm/mongodb/Proxies/_CG_TestBundleDocumentPictures.php’
(include_path=’.:…/library:/usr/local/zend/share/pear’) in
…./test/vendor/doctrine-mongodb-odm/lib/Doctrine/ODM/MongoDB/Proxy/ProxyFactory.php
on line 100

thanks, jan

  • 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-07T01:09:28+00:00Added an answer on June 7, 2026 at 1:09 am

    Ok i found the error:

    In the deps file i have the following lines:

    [doctrine-common]
        git=http://github.com/doctrine/common.git
        version=2.1.4
    
    [doctrine-dbal]
        git=http://github.com/doctrine/dbal.git
        version=2.1.7
    
    [doctrine]
        git=http://github.com/doctrine/doctrine2.git
        version=2.1.7
    

    After updating them to:

    [doctrine-common]
        git=http://github.com/doctrine/common.git
        version=2.2.1
    
    [doctrine-dbal]
        git=http://github.com/doctrine/dbal.git
        version=2.2.1
    
    [doctrine]
        git=http://github.com/doctrine/doctrine2.git
        version=2.2.1
    

    And doing php bin/vendors update the references will work again

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

Sidebar

Related Questions

Hello guys I'm using C and GTK+ 2 I want to make a simple
Hi guys i have my array below and i want to retrieve two rows:as
Hey guys, I want to store a categorized list of URLs. This is an
Hi guys I have the following code and and I want it to last
Hay guys, i want to use something like this users = User.objects.all() but i
Hey guys, I'm starting to play around with Objective-C and I want to make
Ok this is a continuation from this question: How to make a simple Hello
I want to make a simple code to load balance my 2 vps. I
guys I want to start programing with C++. I have written some programs in
Guys, this can't be for real I'm trying to make a .NET 2.0 executable

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.