使用 generate.php 时出现致命错误

Fatal Error with Doctrine while using generate.php(使用 generate.php 时出现致命错误)
本文介绍了使用 generate.php 时出现致命错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在 http://www.Doctrine-project.org/上编写 Doctrine 教程 当我尝试运行生成模型并在数据库中创建表的 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 ...modelsCharity.php on line 14

生成.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');  

你当然可以多次使用它:

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 时出现致命错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Convert JSON integers and floats to strings(将JSON整数和浮点数转换为字符串)
in php how do I use preg replace to turn a url into a tinyurl(在php中,如何使用preg替换将URL转换为TinyURL)
all day appointment for ics calendar file wont work(ICS日历文件的全天约会不起作用)
trim function is giving unexpected values php(Trim函数提供了意外的值php)
Basic PDO connection to MySQL(到MySQL的基本PDO连接)
PHP number_format returns 1.00(Php number_Format返回1.00)