Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Delivered-To: [email protected]
- Received: by 10.220.13.71 with SMTP id b7cs129152vca;
- Tue, 29 Mar 2011 02:57:36 -0700 (PDT)
- Return-Path: <[email protected]>
- Received-SPF: pass (google.com: domain of [email protected] designates 10.223.74.85 as permitted sender) client-ip=10.223.74.85;
- Authentication-Results: mr.google.com; spf=pass (google.com: domain of [email protected] designates 10.223.74.85 as permitted sender) smtp.mail=doctrine-user+bncCJbc0OqdHhCH2sbsBBoEIHL0fg@googlegroups.com; dkim=pass header.i=doctrine-user+bncCJbc0OqdHhCH2sbsBBoEIHL0fg@googlegroups.com
- Received: from mr.google.com ([10.223.74.85])
- by 10.223.74.85 with SMTP id t21mr1907042faj.17.1301392655801 (num_hops = 1);
- Tue, 29 Mar 2011 02:57:35 -0700 (PDT)
- DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
- d=googlegroups.com; s=beta;
- h=domainkey-signature:x-beenthere:received-spf:to:subject
- :mime-version:date:from:in-reply-to:references:message-id:x-sender
- :user-agent:x-original-sender:x-original-authentication-results
- :reply-to:precedence:mailing-list:list-id:x-google-group-id
- :list-post:list-help:list-archive:sender:list-unsubscribe
- :content-type;
- bh=qV9rDKxNYG0wY7AW9RBKqIUZ3AVGoEI7foYmQWMAeTE=;
- b=OLa9CiP2KVxqwiXPSQg9a9YdUn9P9RPoXwt7vPiWwLrO83D/9ROkBUQQSJCcRNUQPB
- YXofBDQMuH3iuff5v4rTZYyRSkcybD+2r8OPHU6F3zBy05OKXiVfHgUp//ldAihSYDAQ
- MuSmR9P9iz+FF+MkdXA134bP0l5zXOaAa0WLk=
- DomainKey-Signature: a=rsa-sha1; c=nofws;
- d=googlegroups.com; s=beta;
- h=x-beenthere:received-spf:to:subject:mime-version:date:from
- :in-reply-to:references:message-id:x-sender:user-agent
- :x-original-sender:x-original-authentication-results:reply-to
- :precedence:mailing-list:list-id:x-google-group-id:list-post
- :list-help:list-archive:sender:list-unsubscribe:content-type;
- b=c/X8XZZq14LhTwJHyML5uztiZoFtCZ7xh+w6ZL5TY4stSj2IMBNSSc3L8LZd9DUjOC
- JbrFjCo47aVhfCfd2KbZMnGr8UreEDWuz2ZxqeOqcJJY0tvVXARJ6TbKu413P51WNGCh
- mxzDbTylneutCrvPS6caS5kIjDSDV1a+Ugf3g=
- Received: by 10.223.74.85 with SMTP id t21mr549673faj.17.1301392648533;
- Tue, 29 Mar 2011 02:57:28 -0700 (PDT)
- X-BeenThere: [email protected]
- Received: by 10.223.15.10 with SMTP id i10ls1406705faa.1.p; Tue, 29 Mar 2011
- 02:57:26 -0700 (PDT)
- Received: by 10.223.144.68 with SMTP id y4mr593740fau.24.1301392646614;
- Tue, 29 Mar 2011 02:57:26 -0700 (PDT)
- Received: by 10.223.144.68 with SMTP id y4mr593739fau.24.1301392646599;
- Tue, 29 Mar 2011 02:57:26 -0700 (PDT)
- Received: from beberlei.de (lvps178-77-98-152.dedicated.hosteurope.de [178.77.98.152])
- by gmr-mx.google.com with ESMTP id p7si76128faa.9.2011.03.29.02.57.25;
- Tue, 29 Mar 2011 02:57:25 -0700 (PDT)
- Received-SPF: neutral (google.com: 178.77.98.152 is neither permitted nor denied by best guess record for domain of [email protected]) client-ip=178.77.98.152;
- Received: by beberlei.de (Postfix, from userid 33)
- id 6B06C6E090ED; Tue, 29 Mar 2011 11:57:25 +0200 (CEST)
- To: <[email protected]>
- Subject: Re: [doctrine-user] Checking existance of a one to one relation
- MIME-Version: 1.0
- Date: Tue, 29 Mar 2011 11:57:25 +0200
- From: Benjamin Eberlei <[email protected]>
- In-Reply-To: <[email protected]>
- References: <0e0d2d69-214e-4d5c-9bc2-6903f485e18b@d28g2000yqc.googlegroups.com> <[email protected]>
- Message-ID: <[email protected]>
- X-Sender: [email protected]
- User-Agent: RoundCube Webmail/0.3.1
- X-Original-Sender: [email protected]
- X-Original-Authentication-Results: gmr-mx.google.com; spf=neutral (google.com:
- 178.77.98.152 is neither permitted nor denied by best guess record for domain
- Reply-To: [email protected]
- Precedence: list
- Mailing-list: list [email protected]; contact [email protected]
- List-ID: <doctrine-user.googlegroups.com>
- X-Google-Group-Id: 52941642618
- List-Post: <http://groups.google.com/group/doctrine-user/post?hl=en_US>, <mailto:[email protected]>
- List-Help: <http://groups.google.com/support/?hl=en_US>, <mailto:[email protected]>
- List-Archive: <http://groups.google.com/group/doctrine-user?hl=en_US>
- Sender: [email protected]
- List-Unsubscribe: <http://groups.google.com/group/doctrine-user/subscribe?hl=en_US>,
- <mailto:[email protected]>
- Content-Type: text/plain; charset=ISO-8859-1
- Besides the isset/private problem Marco already wrote,
- your @OneToOne has two owning sides, which means two foreign keys are
- created. You want to look into "mappedBy" and "inversedBy" to restrict this
- to one foreign key only.
- On Tue, 29 Mar 2011 11:41:39 +0200, Marco Pivetta <[email protected]>
- wrote:
- > First of all, it's a private var, and you don't have any getters or
- setters
- > defined.
- > Supposing you have User#getProfile() { return $this->profile; } you
- should
- > just check
- > if(empty($user->getProfile()) { /* OMG! */ }
- > Marco Pivetta
- > @Ocramius <http://twitter.com/Ocramius>
- > http://marco-pivetta.com
- >
- >
- >
- > On 29 March 2011 11:38, Ivo Roes <[email protected]> wrote:
- >
- >> I have a simple example:
- >>
- >> class User {
- >> /**
- >> * @var integer $id
- >> */
- >> private $id
- >>
- >> /**
- >> * @var text $name
- >> */
- >> private $name
- >>
- >> /**
- >> * @OneToOne(targetEntity="Profile")
- >> * @JoinColumn(name="id", referencedColumnName="id")
- >> */
- >> private $profile;
- >>
- >> }
- >>
- >> class Profile {
- >> /**
- >> * @var integer $id
- >> */
- >> private $id
- >>
- >> /**
- >> * @var text $info
- >> */
- >> private $info
- >>
- >> /**
- >> * @OneToOne(targetEntity="User")
- >> * @JoinColumn(name="id", referencedColumnName="id")
- >> */
- >> private $user;
- >>
- >> }
- >>
- >> Now in my case it is possible that a user doesnt have a profile, but
- >> if he does have one, it can be atmost one. So actually its a 0 to 1
- >> relationship. I want to test for a certain user if he has a related
- >> profile. So I use:
- >>
- >> $u = $entityManager->find("User",1);
- >> var_dump(isset($u->profile));
- >>
- >> But this always returns false. Is there a way to check if a related
- >> entity exists?
- >>
- >> --
- >> You received this message because you are subscribed to the Google
- Groups
- >> "doctrine-user" group.
- >> To post to this group, send email to [email protected].
- >> To unsubscribe from this group, send email to
- >> For more options, visit this group at
- >> http://groups.google.com/group/doctrine-user?hl=en.
- >>
- >>
- --
- You received this message because you are subscribed to the Google Groups "doctrine-user" group.
- To post to this group, send email to [email protected].
- To unsubscribe from this group, send email to [email protected].
- For more options, visit this group at http://groups.google.com/group/doctrine-user?hl=en.
Advertisement
Add Comment
Please, Sign In to add comment