as about my previous question: I guess this should because that both
entities are mapped by identifiers of each other (as they are one to one)
rather than the owning side having a FK? Should be that the issue?

On Tue, Nov 24, 2015 at 5:30 PM, Nima Sadjadi <[email protected]> wrote:

>
> I have this hasser method in my User entity:
>
>     public function hasCity()
>     {
>         return $this->city instanceof City;
>     }
>
> Then in my script I have:
>
> $user = $em->find(User.....);
> if ($user->hasCity()) {
>          $city = $user->getCity();
>          $zip = $city->getZip();
>     } else {
>     $city = new City;
>     $city->setUser($user);
> }
>
> But I still get Entity City not found error. User and City are oneToOne to
> each other. what wrong I did in my script above?
>
>
>
>
>
> On Wed, Dec 17, 2014 at 10:44 PM, Menno Holtkamp <[email protected]
> > wrote:
>
>> No, the getter (getCity()) would return the instance. The 'hasser' and
>> 'isser' etc would simply return boolean. No need to cast to boolean.
>>
>> http://php.net/manual/en/language.operators.type.php
>>
>> On 17 December 2014 at 22:23, Nima Sadjadi <[email protected]> wrote:
>>>
>>> Menno, sorry for asking much, please bear with newbies! I guess the
>>> hasser you wrote, returns the entity instance? So if we need to check if it
>>> hasCity or does not have, isn't it better to return it with (bool)? Or I am
>>> wrong?
>>>
>>> --
>>> 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