在使用generate.php时,使用原则造成致命错误 [英] Fatal Error with Doctrine while using generate.php

查看:95
本文介绍了在使用generate.php时,使用原则造成致命错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在 http://www.Doctrine-project.org/ ,当我尝试运行我的generate.php脚本时,我收到一个致命的错误,这个脚本使我的模型和数据库中的表成为:

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:

generate.php:

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

和schema.yml

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.

推荐答案

您需要使用Doctrine提供的自动装载机注册模型。不需要使用任何迭代器或者这样的东西

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');  

您当然可以使用sevaral时间:

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'); 

这篇关于在使用generate.php时,使用原则造成致命错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆