Piotr Krajewski

Piotr Krajewski web application
programmer

Temat: sf2 relacja OneToOne

Witam serdecznie,

stworzylem dwa modele:

1. Offer

<?php
namespace Lodge\SiteBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;

/**
* Lodge\SiteBundle\Entity\Offer
*
* @ORM\Table(name="offers")
* @ORM\Entity(repositoryClass="Lodge\SiteBundle\Repository\OfferRepository")
* @ORM\HasLifecycleCallbacks()
*/
class Offer{
/**
* @var integer $id
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;

/**
* @OneToOne(targetEntity="OfferDetails", mappedBy="offers")
*/
private $details;

public function __construct(){
$this->details = new ArrayCollection();
}

/**
* Get id
*
* @return integer
*/
public function getId(){
return $this->id;
}
}


2. OfferDetails

<?php

namespace Lodge\SiteBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
* Lodge\SiteBundle\Entity\OfferDetails
*
* @ORM\Table(name="offer_details")
* @ORM\Entity
*/
class OfferDetails{
/**
* @var integer $id
*
* @ORM\Column(name="id", type="integer", nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;

/**
* @var string $phone
*
* @ORM\Column(name="phone", type="string", length=16, nullable=false)
*/
private $phone;

/**
* @OneToOne(targetEntity="Offer", inversedBy="details")
* @JoinColumn(name="offer_id", referencedColumnName="id")
*/
private $offers;
}


i teraz wywołując takie polecenie:
php app/console doctrine:schema:update --force

wywala mi taki błąd:

[Doctrine\Common\Annotations\AnnotationException]
[Semantical Error] The annotation "@OneToOne" in property Lodge\SiteBundle\Entity\Offer::$details was never imported. Did you maybe forget to add a "use" statement for this annotation?


ma ktos moze pomysl jak to naprawic ?
Krzysztof N.

Krzysztof N. CEO. Aplikacje
internetowe i
mobilne. Symfony,
Zend.

Temat: sf2 relacja OneToOne

Piotr Krajewski:
wywala mi taki błąd:
[Doctrine\Common\Annotations\AnnotationException]             
[Semantical Error] The annotation "@OneToOne" in property Lodge\SiteBundle\Entity\Offer::$details was never imported. Did you maybe forget to add a "use" statement for this annotation?

ma ktos moze pomysl jak to naprawic ?
Zamień @OneToOne na @ORM\OneToOne.
Piotr Krajewski

Piotr Krajewski web application
programmer

Temat: sf2 relacja OneToOne

ehhh :) a szukalem przez godzine - thx :)

Następna dyskusja:

Relacja 1:1 i lista




Wyślij zaproszenie do