Ver Mensaje Individual
  #1 (permalink)  
Antiguo 08/12/2011, 18:44
mrut
 
Fecha de Ingreso: noviembre-2011
Ubicación: peru
Mensajes: 7
Antigüedad: 12 años, 5 meses
Puntos: 0
Pregunta Doctrine 2 como añadir un campo mas a un detalle de tabla

Hola a todos

estoy comenzando con doctrine 2 y trabajando con codeigniter, la estructura es el siguiente:
tengo una entidad llamada user.php

Código PHP:
<?php

namespace models
;

use 
DoctrineORMMapping as ORM;

/**
 * models\User
 *
 * @Table(name="user")
 * @Entity(repositoryClass="models\repositories\UserRepository")
 */
class User
{
    
/**
     * @var integer $id
     *
     * @Column(name="id", type="integer", precision=0, scale=0, nullable=false, unique=false)
     * @Id
     * @GeneratedValue(strategy="IDENTITY")
     */
    
private $id;

    
/**
     * @var string $username
     *
     * @Column(name="username", type="string", length=32, precision=0, scale=0, nullable=false, unique=true)
     */
    
private $username;

    
/**
     * @OneToMany(targetEntity="Usuarioxperfil", mappedBy="userr")
     */
    
private $usuarioper;


    
/**
     * @var string $password
     *
     * @Column(name="password", type="string", length=64, precision=0, scale=0, nullable=false, unique=false)
     */
    
private $password;

    
/**
     * @var string $email
     *
     * @Column(name="email", type="string", length=255, precision=0, scale=0, nullable=false, unique=true)
     */
    
private $email;


    
/**
     * Get id
     *
     * @return integer 
     */

    
public function __construct() {
    
$this->usuarioper = new DoctrineCommonCollectionsArrayCollection();
       }

    public function 
getId()
    {
        return 
$this->id;
    }

    
/**
     * Set username
     *
     * @param string $username
     */
    
public function setUsername($username)
    {
        
$this->username $username;
    }

    
/**
     * Get username
     *
     * @return string 
     */
    
public function getUsername()
    {
        return 
$this->username;
    }

    
/**
     * Set password
     *
     * @param string $password
     */
    
public function setPassword($password)
    {
        
$this->password $password;
    }

    
/**
     * Get password
     *
     * @return string 
     */
    
public function getPassword()
    {
        return 
$this->password;
    }

    
/**
     * Set email
     *
     * @param string $email
     */
    
public function setEmail($email)
    {
        
$this->email $email;
    }

    
/**
     * Get email
     *
     * @return string 
     */
    
public function getEmail()
    {
        return 
$this->email;
    }
}
la siguiente entidad es:

perfil.php
Código PHP:
<?php

namespace models
;

use 
DoctrineORMMapping as ORM;

/**
 * models\Perfil
 *
 * @Table(name="perfil")
 * @Entity(repositoryClass="models\repositories\PerfilRepository")
 */
class Perfil
{
    
/**
     * @var integer $id
     *
     * @Column(name="id", type="integer", precision=0, scale=0, nullable=false, unique=false)
     * @Id
     * @GeneratedValue(strategy="IDENTITY")
     */
    
private $id;

    
/**
     * @var string $nombre
     *
     * @Column(name="nombre", type="string", length=125, precision=0, scale=0, nullable=false, unique=false)
     */
    
private $nombre;

    
/**
     * @OneToMany(targetEntity="Usuarioxperfil", mappedBy="perfill")
     */
    
private $userper;

    
/**
     * @var text $fecha
     *
     * @Column(name="fecha", type="date", precision=0, scale=0, nullable=false, unique=false)
     */
    
private $fecha;

    
/**
     * @ManyToMany(targetEntity="Menu", mappedBy="perfils")
     */
    
private $menuse;

    public function 
__construct(){
        
$this->menuse=new DoctrineCommonCollectionsArrayCollection();
        
$this->userper = new DoctrineCommonCollectionsArrayCollection();
    }

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

    
/**
     * Set nombre
     *
     * @param string $nombre
     */
    
public function setNombre($nombre)
    {
        
$this->nombre $nombre;
    }

    
/**
     * Get nombre
     *
     * @return string 
     */
    
public function getNombre()
    {
        return 
$this->nombre;
    }

    
/**
     * Set fecha
     *
     * @param date $fecha
     */
    
public function setFecha($fecha)
    {
        
$this->fecha $fecha;
    }

    
/**
     * Get fecha
     *
     * @return date 
     */
    
public function getFecha()
    {
        return 
$this->fecha;
    }

    
/**
     * Add menuse
     *
     * @param models\Menu $menuse
     */
    
public function addMenu(modelsMenu $menuse)
    {
        
$this->menuse[] = $menuse;
    }

    
/**
     * Get menuse
     *
     * @return Doctrine\Common\Collections\Collection 
     */
    
public function getMenuse()
    {
        return 
$this->menuse;
    }
}
y eh creado una entidad usuarioxperfil.php q seria el detalle donde quiero añadir un campo mas

Código PHP:
<?php

namespace models
;

use 
DoctrineORMMapping as ORM;

/**
 * models\Perfil
 *
 * @Table(name="perfil")
 * @Entity(repositoryClass="models\repositories\PerfilRepository")
 */
class Perfil
{
    
/**
     * @var integer $id
     *
     * @Column(name="id", type="integer", precision=0, scale=0, nullable=false, unique=false)
     * @Id
     * @GeneratedValue(strategy="IDENTITY")
     */
    
private $id;

    
/**
     * @var string $nombre
     *
     * @Column(name="nombre", type="string", length=125, precision=0, scale=0, nullable=false, unique=false)
     */
    
private $nombre;

    
/**
     * @OneToMany(targetEntity="Usuarioxperfil", mappedBy="perfill", cascade={"persist","remove","merge"}, orphanRemoval=true)
     */
    
private $userper;

    
/**
     * @var text $fecha
     *
     * @Column(name="fecha", type="date", precision=0, scale=0, nullable=false, unique=false)
     */
    
private $fecha;

    
/**
     * @ManyToMany(targetEntity="Menu", mappedBy="perfils")
     */
    
private $menuse;

    public function 
__construct(){
        
$this->menuse=new DoctrineCommonCollectionsArrayCollection();
        
$this->userper = new DoctrineCommonCollectionsArrayCollection();
    }

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

    
/**
     * Set nombre
     *
     * @param string $nombre
     */
    
public function setNombre($nombre)
    {
        
$this->nombre $nombre;
    }

    
/**
     * Get nombre
     *
     * @return string 
     */
    
public function getNombre()
    {
        return 
$this->nombre;
    }

    
/**
     * Set fecha
     *
     * @param date $fecha
     */
    
public function setFecha($fecha)
    {
        
$this->fecha $fecha;
    }

    
/**
     * Get fecha
     *
     * @return date 
     */
    
public function getFecha()
    {
        return 
$this->fecha;
    }

    
/**
     * Add menuse
     *
     * @param models\Menu $menuse
     */
    
public function addMenu(modelsMenu $menuse)
    {
        
$this->menuse[] = $menuse;
    }

    
/**
     * Get menuse
     *
     * @return Doctrine\Common\Collections\Collection 
     */
    
public function getMenuse()
    {
        return 
$this->menuse;
    }
}
la cual al actualizar mi bd por consola me genera el siguiente error:

[Doctrine\ORM\MappingException]
No identifier/primary key specified for Entity 'models\Usuarioxperfil'. Every Entity
must have an identifier/primary key.

que estoy haciendo mal??

gracias por su respuesta