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