2012-02-06 2 views
0

'절에'에 'e.id'1054 내가 가지고있는이 두 모델 나는 $email->getGrupos();을 실행하는 "Grupos"를 얻으려고오류는 -> 열 찾을 수 없습니다 : 알 수없는 열이

{ 
    class Email extends Doctrine_Record 
    { 
     public function setTableDefinition() 
     { 
      $this->setTableName('email'); 
      $this->hasColumn('id', 'integer', 4, array(
       'type' => 'integer', 
       'length' => 4, 
       'fixed' => false, 
       'unsigned' => false, 
       'primary' => true, 
       'autoincrement' => true, 
       )); 
      $this->hasColumn('nombre', 'string', 40, array(
       'type' => 'string', 
       'length' => 40, 
       'fixed' => false, 
       'unsigned' => false, 
       'primary' => false, 
       'notnull' => true, 
       'autoincrement' => false, 
       )); 
      $this->hasColumn('email', 'string', 90, array(
       'type' => 'string', 
       'length' => 90, 
       'fixed' => false, 
       'unsigned' => false, 
       'primary' => false, 
       'notnull' => true, 
       'autoincrement' => false, 
       )); 
      $this->hasColumn('estado', 'integer', 1, array(
       'type' => 'integer', 
       'length' => 1, 
       'fixed' => false, 
       'unsigned' => false, 
       'primary' => false, 
       'default' => '1', 
       'notnull' => true, 
       'autoincrement' => false, 
       )); 
      $this->hasColumn('borrado', 'integer', 1, array(
       'type' => 'integer', 
       'length' => 1, 
       'fixed' => false, 
       'unsigned' => false, 
       'primary' => false, 
       'default' => '0', 
       'notnull' => true, 
       'autoincrement' => false, 
       )); 
      $this->hasColumn('created_at', 'timestamp', null, array(
       'type' => 'timestamp', 
       'fixed' => false, 
       'unsigned' => false, 
       'primary' => false, 
       'notnull' => true, 
       'autoincrement' => false, 
       )); 
      $this->hasColumn('updated_at', 'timestamp', null, array(
       'type' => 'timestamp', 
       'fixed' => false, 
       'unsigned' => false, 
       'primary' => false, 
       'notnull' => true, 
       'autoincrement' => false, 
       )); 
     } 

     public function setUp() 
     { 
      parent::setUp(); 

      $this->hasMany('Grupo as Grupos', array(
        'refClass' => 'EmailGrupo', 
        'local' => 'email_id', 
        'foreign' => 'grupo_id')); 

      $this->hasMany('Envio as Envios', array(
        'local' => 'email_id', 
        'foreign' => 'envio_id', 
        'refClass' => 'EnvioEmail')); 
     } 

     //setters 
     public function setId($id) { $this->_set('id', $id); } 
     public function setNombre($nombre) { $this->_set('nombre', $nombre); } 
     public function setEmail($email) { $this->_set('email', $email); } 
     public function setEstado($estado) { $this->_set('estado', $estado); } 
     public function setBorrado($borrado) { $this->_set('borrado', $borrado); } 

     //getters 
     public function getId() { return $this->_get('id'); } 
     public function getNombre() { return $this->_get('nombre'); } 
     public function getEmail() { return $this->_get('email'); } 
     public function getEstado() { return $this->_get('estado'); } 
     public function getBorrado() { return $this->_get('borrado'); } 
     public function getGrupos() { return $this->_get('Grupos'); } 
     public function getEnvios() { return $this->_get('Envios'); } 

     public function delete(){ 
      $this->setBorrado(1); 
      $this->save(); 
     } 


    } 

} 

{ 

    class EmailGrupo extends Doctrine_Record 
    { 
     public function setTableDefinition() 
     { 
      $this->setTableName('email_grupo'); 
      $this->hasColumn('email_id', 'integer', 4, array(
       'type' => 'integer', 
       'length' => 4, 
       'fixed' => false, 
       'unsigned' => false, 
       'primary' => true, 
       'autoincrement' => false, 
       )); 
      $this->hasColumn('grupo_id', 'integer', 4, array(
       'type' => 'integer', 
       'length' => 4, 
       'fixed' => false, 
       'unsigned' => false, 
       'primary' => true, 
       'autoincrement' => false, 
       )); 
     } 

     public function setUp() 
     { 
      parent::setUp(); 

      $this->hasOne('Email', array(
       'local' => 'email_id', 
       'foreign' => 'id')); 

      $this->hasOne('Grupo', array(
       'local' => 'grupo_id', 
       'foreign' => 'id')); 


     } 

     // setters 
     public function setEmailId($email_id) { $this->_set('email_id', $email_id); } 
     public function setGrupoId($grupo_id) { $this->_set('grupo_id', $grupo_id); } 


     // getters 
     public function getEmailId() { return $this->_get('email_id'); } 
     public function getGrupoId() { return $this->_get('grupo_id'); } 
    } 

} 

내가 쿼리를 기록하고 내가 할

Fatal error: Uncaught exception 'Doctrine_Connection_Mysql_Exception' with message 'SQLSTATE[42S22]: Column not found: 1054 Unknown column 'e.id' in 'on clause'' in F:\Proyectos\Flash Moda\code\application\helpers\doctrine\lib\Doctrine\Connection.php on line 1083.

:

SELECT g.id AS g_id, g.nombre AS g_nombre, g.borrado AS g__borrado, g.created_at AS g__created_at, g.updated_at AS g__updated_at, e.email_id AS e__email_id, e.grupo_id AS e__grupo_id FROM grupo g LEFT JOIN email_grupo e ON g.id = e.id WHERE (e.email_id IN (?))

하면 오른쪽 측면에의 가입 왜이 오류가 틀렸어? 감사

UPDATE : GRUPO 모델을 추가하고 나는 $ 이메일을 어떻게 오류가 GRUPO 모델에

class Grupo extends Doctrine_Record 
{ 
    public function setTableDefinition() 
    { 
     $this->setTableName('grupo'); 
     $this->hasColumn('id', 'integer', 4, array(
      'type' => 'integer', 
      'length' => 4, 
      'fixed' => false, 
      'unsigned' => false, 
      'primary' => true, 
      'autoincrement' => true, 
      )); 
     $this->hasColumn('nombre', 'string', 40, array(
      'type' => 'string', 
      'length' => 40, 
      'fixed' => false, 
      'unsigned' => false, 
      'primary' => false, 
      'notnull' => true, 
      'autoincrement' => false, 
      )); 
     $this->hasColumn('borrado', 'integer', 1, array(
      'type' => 'integer', 
      'length' => 1, 
      'fixed' => false, 
      'unsigned' => false, 
      'primary' => false, 
      'default' => '0', 
      'notnull' => true, 
      'autoincrement' => false, 
      )); 
     $this->hasColumn('created_at', 'timestamp', null, array(
      'type' => 'timestamp', 
      'fixed' => false, 
      'unsigned' => false, 
      'primary' => false, 
      'notnull' => true, 
      'autoincrement' => false, 
      )); 
     $this->hasColumn('updated_at', 'timestamp', null, array(
      'type' => 'timestamp', 
      'fixed' => false, 
      'unsigned' => false, 
      'primary' => false, 
      'notnull' => true, 
      'autoincrement' => false, 
      )); 
    } 

    public function setUp() 
    { 
     parent::setUp(); 

     $this->actAs('Timestampable');  

     $this->hasMany('Email as Emails', array(
       'local' => 'id', 
       'foreign' => 'grupo_id', 
       'refClass' => 'EmailGrupo' 
      ) 
     ); 

     $this->hasMany('Envio as Envios', array(
       'local' => 'id', 
       'foreign' => 'grupo_id', 
       'refClass' => 'EnvioGrupo' 
      ) 
     ); 
    } 

    //setters 
    public function setId($id) { $this->_set('id', $id); } 
    public function setNombre($nombre) { $this->_set('nombre', $nombre); } 
    public function setBorrado($borrado) { $this->_set('borrado', $borrado); } 

    // getters 
    public function getId() { return $this->_get('id'); } 
    public function getNombre() { return $this->_get('nombre'); } 
    public function getBorrado() { return $this->_get('borrado'); } 

    public function delete(){ 
     $this->setBorrado(1); 
     $this->save(); 
    } 

} 

$email = Doctrine::getTable('Email')->find($this->uri->segment(4,0)); 
+0

'$ email' var과 하나 더 많은 모델 -'Grupo'를 게시 할 수 있습니까? 그 모델에서 오류가있는 것 같습니다. – devdRew

+0

Grupo의 정의로 질문을 업데이트하고 $ meail을 얻는 방법 –

답변

0

, 이것은 올바른 모델 :

class Grupo extends Doctrine_Record 
{ 
    public function setTableDefinition() 
    { 
     $this->setTableName('grupo'); 
     $this->hasColumn('id', 'integer', 4, array(
      'type' => 'integer', 
      'length' => 4, 
      'fixed' => false, 
      'unsigned' => false, 
      'primary' => true, 
      'autoincrement' => true, 
      )); 
     $this->hasColumn('nombre', 'string', 40, array(
      'type' => 'string', 
      'length' => 40, 
      'fixed' => false, 
      'unsigned' => false, 
      'primary' => false, 
      'notnull' => true, 
      'autoincrement' => false, 
      )); 
     $this->hasColumn('borrado', 'integer', 1, array(
      'type' => 'integer', 
      'length' => 1, 
      'fixed' => false, 
      'unsigned' => false, 
      'primary' => false, 
      'default' => '0', 
      'notnull' => true, 
      'autoincrement' => false, 
      )); 
     $this->hasColumn('created_at', 'timestamp', null, array(
      'type' => 'timestamp', 
      'fixed' => false, 
      'unsigned' => false, 
      'primary' => false, 
      'notnull' => true, 
      'autoincrement' => false, 
      )); 
     $this->hasColumn('updated_at', 'timestamp', null, array(
      'type' => 'timestamp', 
      'fixed' => false, 
      'unsigned' => false, 
      'primary' => false, 
      'notnull' => true, 
      'autoincrement' => false, 
      )); 
    } 

    public function setUp() 
    { 
     parent::setUp(); 

     $this->actAs('Timestampable');  

     $this->hasMany('Email as Emails', array(
       'local' => 'grupo_id', 
       'foreign' => 'email_id', 
       'refClass' => 'EmailGrupo' 
      ) 
     ); 

     $this->hasMany('Envio as Envios', array(
       'local' => 'grupo_id', 
       'foreign' => 'envio_id', 
       'refClass' => 'EnvioGrupo' 
      ) 
     ); 
    } 

    //setters 
    public function setId($id) { $this->_set('id', $id); } 
    public function setNombre($nombre) { $this->_set('nombre', $nombre); } 
    public function setBorrado($borrado) { $this->_set('borrado', $borrado); } 

    // getters 
    public function getId() { return $this->_get('id'); } 
    public function getNombre() { return $this->_get('nombre'); } 
    public function getBorrado() { return $this->_get('borrado'); } 


} 

내가 선을 hange 전자 메일로 relaicon을 정의합니다.