2011-08-21 13 views
0

教義1.2のZend Frameworkでモデルからテーブルを作成しない

Doctrine::createTablesFromModels(APPLICATION_PATH . '/models'); 

をうまく働いたYAMLファイルからモデルを生成するとは違って、これはでは何もしませんすべて。エラーなし、警告なし、何もありません。テーブルは作成されません。下のコードを実行すると、正常に動作します。

Doctrine::dropDatabases(); 

したがって、データベース接続は機能し、権限は正しく設定されています。私は10の異なった方法でそれをgoogledしました。何の役に立つ答えも得られなかったので、今私はここで尋ねています。ここで

は私の基底クラスの1つである:私はその前に、この問題に直面し、私はそれの終わりに解決 を見つけることができませんでした検索の3日後に私が使用して移動していたていた

<?php 

/** 
* BaseUser 
* 
* This class has been auto-generated by the Doctrine ORM Framework 
* 
* @property string $email 
* @property string $password 
* @property string $firstName 
* @property string $lastName 
* @property string $profileText 
* @property integer $role_id 
* @property Role $Role 
* @property Doctrine_Collection $UserDetail 
* @property Doctrine_Collection $CalendarItem 
* @property Doctrine_Collection $NewsItem 
* @property Doctrine_Collection $Link 
* @property Doctrine_Collection $TwitterUser 
* @property Doctrine_Collection $Tweet 
* 
* @package ##PACKAGE## 
* @subpackage ##SUBPACKAGE## 
* @author  ##NAME## <##EMAIL##> 
* @version SVN: $Id: Builder.php 6820 2009-11-30 17:27:49Z jwage $ 
*/ 
abstract class BaseUser extends Doctrine_Record 
{ 
    public function setTableDefinition() 
    { 
     $this->setTableName('user'); 
     $this->hasColumn('email', 'string', 255, array(
      'type' => 'string', 
      'length' => '255', 
      )); 
     $this->hasColumn('password', 'string', 255, array(
      'type' => 'string', 
      'length' => '255', 
      )); 
     $this->hasColumn('firstName', 'string', 255, array(
      'type' => 'string', 
      'length' => '255', 
      )); 
     $this->hasColumn('lastName', 'string', 255, array(
      'type' => 'string', 
      'length' => '255', 
      )); 
     $this->hasColumn('profileText', 'string', null, array(
      'type' => 'string', 
      'length' => '', 
      )); 
     $this->hasColumn('role_id', 'integer', 8, array(
      'type' => 'integer', 
      'length' => 8, 
      )); 

     $this->option('collate', 'utf8_unicode_ci'); 
     $this->option('charset', 'utf8'); 
    } 

    public function setUp() 
    { 
     parent::setUp(); 
     $this->hasOne('Role', array(
      'local' => 'role_id', 
      'foreign' => 'id')); 

     $this->hasMany('UserDetail', array(
      'local' => 'id', 
      'foreign' => 'user_id')); 

     $this->hasMany('CalendarItem', array(
      'local' => 'id', 
      'foreign' => 'user_id')); 

     $this->hasMany('NewsItem', array(
      'local' => 'id', 
      'foreign' => 'user_id')); 

     $this->hasMany('Link', array(
      'local' => 'id', 
      'foreign' => 'user_id')); 

     $this->hasMany('TwitterUser', array(
      'local' => 'id', 
      'foreign' => 'user_id')); 

     $this->hasMany('Tweet', array(
      'local' => 'id', 
      'foreign' => 'user_id')); 

     $timestampable0 = new Doctrine_Template_Timestampable(); 
     $softdelete0 = new softDelete(); 
     $this->actAs($timestampable0); 
     $this->actAs($softdelete0); 
    } 
} 
+1

私たちはあなたのモデルの一つ+基底クラスを参照してくださいもらえますか? – adlawson

+0

基本クラスの1つを追加しました。私はモデルを変更していないので、基本クラスを拡張した空のクラスに過ぎません。 –

+0

もちろん、テーブルを手作業で作成することもできますが、それは単なる回避策であり、通常のコードを正常に動作させたいだけです。 –

答えて

1

問題は解決されました。私はソフト削除機能を使用していましたが、設定するのを忘れました。

$manager->setAttribute(Doctrine_Core::ATTR_USE_DQL_CALLBACKS, true); 

これはソフト削除には必要です。私も生成されたモデルで、それはsoftdeletionのために間違ったコードを使用していることが分かった:

$softdelete0 = new softDelete(); 

の代わりに:

$softdelete0 = new Doctrine_Template_SoftDelete(); 
-1

symfony cliツールを使用してSQLを生成し、yamlファイルからdbを作成します

+0

これは疑問の答えではなく、むしろまっすぐ進む問題を回避する方法です。確かに、OPがまだ有用な情報を投稿していないので、あなたはまだ質問に完全な答えを出すことはできませんが、私はテーブル生成を扱うために全く異なる方法を提供するほど早くはありません。 – adlawson

+0

時間を節約し、仕事を手に入れようとしているだけの回避策です。回答があれば喜んで使用します – tawfekov

+0

最初にあなたのモデルとベースクラスを見ることなく、やや難しくて – adlawson

関連する問題