我刚刚将我的环境(ubuntu)中的Doctrine 1.2.1与Zend Framework一起工作。 当我运行我的学说命令
时./ doctrine build-all-reload
它给了我输出:
build-all-reload - Are you sure you wish to drop your databases? (y/n)
y
build-all-reload - SQLSTATE[HY000]: General error: 1008 Can't drop database 'zcdev'; database doesn't exist. Failing Query: "DROP DATABASE zcdev"
build-all-reload - Generated models successfully from YAML schema
build-all-reload - Successfully created database for connection named 'doctrine'
build-all-reload - Created tables successfully
build-all-reload - Data was successfully loaded
但是当我用phpMyAdmin查看我的数据库时,我发现我的数据库已创建,但不是我的表。
这是我的yml文件:
options:
type: INNODB
collate: utf_general_ci
charset: utf8
Events:
columns:
evt_id:
type: integer
primary: true
autoincrement: true
evt_name: string(200)
evt_description: string(200)
evt_startdate: date
evt_enddate: date
evt_starttime: time
evt_endtime: time
evt_amtpersons: integer
我通过重命名检查它是否真的使用了我的yml文件,这是因为当我重命名我的yml文件时,我得到了相应的错误。 那么任何想法都是?
答案 0 :(得分:1)
设置自动加载时是否包含spl_autoload_register?这是我的Bootstrap.php文件中的initDoctrine函数:
public function _initDoctrine() { $this->getApplication()->getAutoloader() ->pushAutoloader(array('Doctrine', 'autoload')); spl_autoload_register(array('Doctrine', 'modelsAutoload')); $manager = Doctrine_Manager::getInstance(); $manager->setAttribute(Doctrine::ATTR_AUTO_ACCESSOR_OVERRIDE, true); $manager->setAttribute(Doctrine::ATTR_MODEL_LOADING, Doctrine::MODEL_LOADING_CONSERVATIVE); $manager->setAttribute(Doctrine::ATTR_AUTOLOAD_TABLE_CLASSES, true); $doctrineConfig = $this->getOption('doctrine'); Doctrine::loadModels($doctrineConfig['models_path']); $conn = Doctrine_Manager::connection($doctrineConfig['dsn'],'doctrine'); $conn->setAttribute(Doctrine::ATTR_USE_NATIVE_ENUM, true); return $conn; }