2010-12-11 12 views
0

DoctrineのcreateTablesFromModelsメソッドを使用してモデルからテーブルを作成しようとしています。私は/modelフォルダを所有していますが、テーブルの生成方法はファイル名によって異なります。Doctrine、異なるファイル名、異なるテーブルの生成

私は、次のされたファイル3内側:

class Item extends Doctrine_Record { 

public function setTableDefinition() { 
    $this->hasColumn('nombre', 'string', 45, array(
     'notnull' => true 
    )); 
    $this->hasColumn('enunciado', 'string', 90, array(
     'notnull' => true 
    )); 
    $this->hasColumn('imagen_reposo', 'string', 90); 
    $this->hasColumn('imagen_movimiento', 'string', 90); 
} 

public function setUp() { 
    $this->hasMany('Prueba as Pruebas', array(
     'refClass' => 'ItemPrueba', 
     'local' => 'item_id', 
     'foreign' => 'prueba_id' 
    )); 
} 
} 

class Prueba extends Doctrine_Record { 

public function setTableDefinition() { 
    $this->hasColumn('nombre', 'string', 45, array(
     'notnull' => true 
    )); 
    $this->hasColumn('consigna', 'clob', 65535); 
    $this->hasColumn('consentimiento', 'clob', 65535); 
    $this->hasColumn('codigo', 'string', 45); 
} 

public function setUp() { 
    $this->hasMany('Item as Items', array(
     'refClass' => 'ItemPrueba', 
     'local' => 'prueba_id', 
     'foreign' => 'item_id' 
    )); 
} 
} 

class ItemPrueba extends Doctrine_Record { 

public function setTableDefinition() { 
    $this->hasColumn('item_id', 'integer', null, array(
     'primary' => true 
    )); 
    $this->hasColumn('prueba_id', 'integer', null, array(
     'primary' => true 
    )); 
} 
} 

は、私はちょうど、多くの関係に多くをしたいです。 私はこの名前を使用する場合:

/models/tableone.php 
/models/tabletwo.php 
/models/tableoneTabletwo.php 

を、それがの関係で、以下の表を作成します。

http://i52.tinypic.com/25hpdo2.png

私は、この名前を使用し

は:

/models/item.php 
/models/prueba.php 
/models/itemPrueba.php 

それはどんな関係なしにテーブルを作成

詳細: 私はCodeIgniterのフレームワークを使用したとして教義1.2を追加していますプラグイン

答えて

0

$this->setTableName('tablename'); 

が必要です。 Doctrineは関係とテーブルを特定するためにいくつかの規則を使用します。これは、通常、クラスに基づいてテーブルの名前を推測しますが、私はこれが何度も失敗したのを見ました。テーブル名を設定することで、必要な処理を行う必要があります。

+0

回答ありがとうございますが、うまくいきませんでした。私はファイル名prueba.phpをprueb.phpに変更しなければならなかった。奇妙な解決策、私はまだ私のモデルクラスでファイル名prueba.phpを使用することができない理由を知らない。 – petingo0

関連する問題