douqiao8370 2010-07-22 09:45
浏览 33
已采纳

使用generate.php时Doctrine的致命错误

I'm working on the Doctrine tutorial at http://www.Doctrine-project.org/ and I receive a fatal error when I try to run my generate.php script which makes my models and makes tables in the database:

Fatal error: Class 'BaseCharity' not found in ...\models\Charity.php on line 14

generate.php:

require_once('bootstrap.php');
Doctrine_Core::dropDatabases();
Doctrine_Core::createDatabases();
Doctrine_Core::generateModelsFromYaml('schema.yml', 'models');
Doctrine_Core::createTablesFromModels('models');

and schema.yml

Charity:
  actAs: [Timestampable]
  columns:
    active:
      type: boolean
      default: '1'
    owed: decimal(32,2)
    totalPayed: decimal(32,2)
    name: string(255)
    website: string(255)
    description: text
    icon: string(255)

I am quite stumped by this, I can get it to correctly create other tables that are very similar or much more complicated then this one. I've tried rewriting it as well. I really have no clue where this error is coming from.

  • 写回答

2条回答 默认 最新

  • dth981485742 2010-07-23 09:23
    关注

    You need to register the models with the autoloader provided by Doctrine. No need to use any Iterators or what so ever

    Doctrine::loadModels('path/to/your/models');  
    

    You can of course use it sevaral times:

    Doctrine::loadModels('path/to/your/models/generated'); 
    Doctrine::loadModels('path/to/your/models/custom');    
    Doctrine::loadModels('path/to/your/models'); 
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)
编辑
预览

报告相同问题?