please read my previous answer. since I am not getting an order for
->getInfo() should I assume that my info entity is loaded? if yes, then why
should I get "entity was not found error" when calling a method inside info
entity, e.g. setFields() ?




On Sun, Apr 20, 2014 at 11:32 PM, Nima Sadjadi <[email protected]> wrote:

>
> yes, setField is a method in my Entities\Info.php, by that getInfo(), in
> previous email I tried to get Info entity via product->order then via
> order->info within a loop as you suggested, then to update some properties
> in Info entity  and I get this error, for sure my proxies are still
> auto-generated.
>
>
> Fatal error: Uncaught exception 'Doctrine\ORM\EntityNotFoundException'
> with message 'Entity was not found.' in
> /vendor/doctrine/orm/lib/Doctrine/ORM/Proxy/ProxyFactory.php:177 Stack
> trace: #0 /Proxies/__CG__EntitiesInfo.php(227):
> Doctrine\ORM\Proxy\{closure}(Object(Proxies\__CG__\Entities\Info),
> 'setFields', Array) #1 /Proxies/__CG__EntitiesInfo.php(227):
> Closure->__invoke(Object(Proxies\__CG__\Entities\Info), 'setFields', Array)
> #2 /myscript.php(101): Proxies\__CG__\Entities\Info->setFields(Array,
> Array) #3 {main} thrown in
> /vendor/doctrine/orm/lib/Doctrine/ORM/Proxy/ProxyFactory.php on line 177
>
>
>
> On Sun, Apr 20, 2014 at 11:18 PM, Herman Peeren 
> <[email protected]>wrote:
>
>> Is that setFields() defined in your entity? How is the Info-entity
>> defined? What was the exact error message?
>>
>> On Sunday, 20 April 2014 20:08:21 UTC+2, Parsifal wrote:
>>
>>>
>>> Thanks a lot Herman, I did this:
>>>
>>> foreach ($orders as $order) {
>>>               $info = $order->getInfo();
>>>               $info->setFields($_POST, array(.....));
>>> }
>>> Now I get entity was not found for setField(), now getInfo() does not
>>> give error like before. How can I load $info as entity to update some
>>> properties?
>>>
>>>
>>>
>>>
>>>
>>>
>>> On Sun, Apr 20, 2014 at 6:34 PM, Herman Peeren <[email protected]>wrote:
>>>
>>>> $em->find('Entities\Product', $_POST['productId'])->getOrders() gives
>>>> back a collection (of orders).
>>>> You now try to do getInfo() on that collection, but Doctrine's
>>>> collection class doen't have a getInfo() method.
>>>>
>>>> If you want to do a getInfo() on each individual order, so you'll have
>>>> to loop through the collection:
>>>>
>>>> foreach ($orders as $order) {
>>>>     $productInfo = $order->getInfo(); // and do something with that
>>>> $productInfo.
>>>>
>>>> }
>>>>
>>>>
>>>>
>>>> On Sunday, 20 April 2014 14:21:18 UTC+2, Parsifal wrote:
>>>>
>>>>> Thanks herman for helping me how to use getProduct method rather than
>>>>> dql.
>>>>> Just a question:
>>>>>
>>>>> relation from Product to Order:
>>>>> $metadata->mapOneToMany(array( 'fieldName' => 'orders',
>>>>>                                'targetEntity' => 'Entities\\Order',
>>>>>                                'mappedBy' => 'product',
>>>>>                                'joinColumns' => array( 0 => array(
>>>>> 'name' => 'product_id',
>>>>>
>>>>> 'referencedColumnName' => 'product_id',
>>>>>
>>>>> 'nullable' => true,
>>>>>
>>>>> 'columnDefinition' => NULL,
>>>>>                                                       ), )
>>>>> ));
>>>>>
>>>>> In product entity I defined:
>>>>>     public function getOrders()
>>>>>     {
>>>>>          return $this->orders;
>>>>>     }
>>>>>
>>>>> ======
>>>>> relation from Order to Info:
>>>>> $metadata->mapOneToOne(array( 'fieldName' => 'info',
>>>>>                                'targetEntity' => 'Entities\\Info',
>>>>>                                'inversedBy' => 'order',
>>>>>                                'mappedBy' => 'order',
>>>>>                                'joinColumns' => array( 0 => array(
>>>>> 'name' => 'id',
>>>>>
>>>>> 'referencedColumnName' => 'order_id',
>>>>>
>>>>> 'nullable' => true,
>>>>>
>>>>> 'columnDefinition' => NULL,
>>>>>                                                       ), )
>>>>> ));
>>>>>
>>>>> In order entiry I defined:
>>>>>     public function getInfo()
>>>>>     {
>>>>>          return $this->info;
>>>>>     }
>>>>>
>>>>> Now I need to have:
>>>>> $products = $em->find('Entities\Product', $_POST['productId'])->
>>>>> getOrders()->getInfo();
>>>>>
>>>>> But I get:
>>>>> Call to undefined method Doctrine\ORM\PersistentCollection::getInfo()
>>>>> but I have getInfo() method in Order entity, what wrong I did?
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> On Fri, Apr 4, 2014 at 1:38 PM, Herman Peeren <[email protected]>wrote:
>>>>>
>>>>>> All I was saying there is that your:
>>>>>>
>>>>>>
>>>>>>     public function getProduct() {
>>>>>>        return $this->ProductId;
>>>>>>      }
>>>>>>
>>>>>> Sould be something like:
>>>>>>
>>>>>>     public function getProduct() {
>>>>>>        return $this->*product*; // Return a Product, not an id of a
>>>>>> Product.
>>>>>>      }
>>>>>>
>>>>>>
>>>>>> On Friday, 4 April 2014 10:29:32 UTC+2, Parsifal wrote:
>>>>>>
>>>>>>> Thanks Herman,
>>>>>>> A bit confusion in your last email to me as below. If I understood
>>>>>>> correctly in getProduct function it should be something like:
>>>>>>> fuction getProduct($id) {
>>>>>>>    return $em->find('Product', $id);
>>>>>>> }
>>>>>>> Right? And this function should be in Product entity class file
>>>>>>> itself?
>>>>>>> Please clarify if I understood you correctly.
>>>>>>> در 2014 3 20 22:45، "Herman Peeren" <[email protected]> نوشت:
>>>>>>>
>>>>>>>>  Hmmm was about to finally shut down my computer and saw your last
>>>>>>>> message.* NO!!!* *getProduct() doen't return a ProductId but a
>>>>>>>> Product!!!* That is the essence of why we do this all! In
>>>>>>>> getProduct() you have nothing to do with an id. It's just what the name
>>>>>>>> sais: getProduct() gets a Product, can't be simpler. Idem with 
>>>>>>>> getInfo().
>>>>>>>> The id is only necessary for the mapping. And maybe if you want to 
>>>>>>>> find a
>>>>>>>> specific Product outside of this model.
>>>>>>>>
>>>>>>>>
>>>>>>>> On Thursday, 20 March 2014 22:24:51 UTC+1, Parsifal wrote:
>>>>>>>>>
>>>>>>>>> Thanks a lot. Just a quick check with you for sure:
>>>>>>>>> In "X" entity I add this:
>>>>>>>>>
>>>>>>>>> public function getProduct() {
>>>>>>>>>    return $this->ProductId;
>>>>>>>>> }
>>>>>>>>>
>>>>>>>>> Then in "Info" entity I have this:
>>>>>>>>>
>>>>>>>>> public function getInfo() {
>>>>>>>>>    return $this->ProductId;
>>>>>>>>> }
>>>>>>>>>
>>>>>>>>> Then use with:
>>>>>>>>> $specificX->getProduct()-getInfo();
>>>>>>>>>
>>>>>>>>> Right? Or what these functions should be? I guess getInfo() should
>>>>>>>>> be in Product entity instead of Info entity? If yes, what should be 
>>>>>>>>> inside
>>>>>>>>> the function that it loads Info entity?
>>>>>>>>>
>>>>>>>>  --
>>>>>>>> You received this message because you are subscribed to the Google
>>>>>>>> Groups "doctrine-user" group.
>>>>>>>> To unsubscribe from this group and stop receiving emails from it,
>>>>>>>> send an email to [email protected].
>>>>>>>> To post to this group, send email to [email protected].
>>>>>>>>
>>>>>>>> Visit this group at http://groups.google.com/group/doctrine-user.
>>>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>>>
>>>>>>>  --
>>>>>> You received this message because you are subscribed to the Google
>>>>>> Groups "doctrine-user" group.
>>>>>> To unsubscribe from this group and stop receiving emails from it,
>>>>>> send an email to [email protected].
>>>>>> To post to this group, send email to [email protected].
>>>>>> Visit this group at http://groups.google.com/group/doctrine-user.
>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>
>>>>>
>>>>>  --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "doctrine-user" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>> an email to [email protected].
>>>> To post to this group, send email to [email protected].
>>>> Visit this group at http://groups.google.com/group/doctrine-user.
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>>
>>>  --
>> You received this message because you are subscribed to the Google Groups
>> "doctrine-user" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To post to this group, send email to [email protected].
>> Visit this group at http://groups.google.com/group/doctrine-user.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to