Zend_Tool,create db-table.from-database在项目中不起作用(找不到模块)

时间:2022-07-11 11:10:47

I have a Zend Framework project with an existing database, so I'd like to create models based on the tables that I have in my database. I can run zf commands from the command-line and in Netbeans just fine, for example generating controllers/forms works just fine. However, when I want to create the model from the database using the command

我有一个带有现有数据库的Zend Framework项目,所以我想根据我在数据库中的表创建模型。我可以从命令行和Netbeans中运行zf命令就好了,例如生成控制器/表单就可以了。但是,当我想使用命令从数据库创建模型时

zf create db-table.from-database application force-overwrite

it gives me this error:

它给了我这个错误:

A models directory was not found for module application.               

Zend Framework Command Line Console Tool v1.12.1
Details for action "Create" and provider "DbTable"
  DbTable
    zf create db-table name actual-table-name module force-overwrite
    zf create db-table.from-database module force-overwrite

The same thing happens when I try it with

当我尝试使用时,会发生同样的事情

zf create db-table.from-database Application force-overwrite

Just to clarify: the models directory DOES exist in my project folder. I'm assuming I have to enter application because it's the module I'm working in (the default one).

只是为了澄清:models目录是否存在于我的项目文件夹中。我假设我必须输入应用程序,因为它是我正在使用的模块(默认模块)。

My database connection is fine too, since I can execute queries just fine. Has anyone got an idea on how to fix this?

我的数据库连接也很好,因为我可以很好地执行查询。有没有人知道如何解决这个问题?

3 个解决方案

#1


0  

I've not used this feature, but 'application' is not a module. If you don't want it to scan a specific module folder I would guess you leave that parameter out. What happens if you just call zf create db-table.from-database force-overwrite?

我没有使用过这个功能,但“应用程序”不是一个模块。如果你不想让它扫描一个特定的模块文件夹,我猜你会把这个参数留下来。如果你只是调用zf create db-table.from-database force-overwrite会发生什么?

#2


0  

As with most things the problem can be as simple as a case sensitive and/or miss spelled directory name/path. I don't believe this problem can be solved without interaction/emulation.

与大多数事情一样,问题可以像区分大小写和/或拼错目录名称/路径一样简单。我不相信没有交互/仿真就可以解决这个问题。

#3


0  

I've never seen zf create db-table.from-database work in any circumstances. However if you want to try the netbeans command that should work is -m default ('default' is the module, add -f for force overwrite) the resulting command will look like: zf create db-table.from-database -m default.

我从来没有在任何情况下看到zf create db-table.from-database工作。但是,如果要尝试运行的netbeans命令是-m default('default'是模块,添加-f for force overwrite),结果命令将如下所示:zf create db-table.from-database -m default 。

Personally I just use the zf create db-table command to create just the db-table models I need.

我个人只是使​​用zf create db-table命令来创建我需要的db-table模型。

This command would work zf create db-table users users -m admin -f where -m admin(the -m does seem to be required) is the module and -f indicates force over write. The first users is the name of the class (Application_Model_DbTable_Users, Users.php), the second users is the actual name of the database table.

这个命令可以工作zf create db-table users users -m admin -f其中-m admin(-m似乎需要)是模块,-f表示强制写入。第一个用户是类的名称(Application_Model_DbTable_Users,Users.php),第二个用户是数据库表的实际名称。

I don't know what you're expecting as far a model goes, what you're going to get is something very similar to:

我不知道你对模型的期望是什么,你将得到的东西非常类似于:

<?php

class Application_Model_DbTable_User extends Zend_Db_Table_Abstract
{
    protected $_name    = 'users';
}

This a very important class when using the Zend_Db component but if you're new to ZF it may be a little confusing.

这是使用Zend_Db组件时非常重要的一个类,但如果你是ZF的新手,可能会有点混乱。

#1


0  

I've not used this feature, but 'application' is not a module. If you don't want it to scan a specific module folder I would guess you leave that parameter out. What happens if you just call zf create db-table.from-database force-overwrite?

我没有使用过这个功能,但“应用程序”不是一个模块。如果你不想让它扫描一个特定的模块文件夹,我猜你会把这个参数留下来。如果你只是调用zf create db-table.from-database force-overwrite会发生什么?

#2


0  

As with most things the problem can be as simple as a case sensitive and/or miss spelled directory name/path. I don't believe this problem can be solved without interaction/emulation.

与大多数事情一样,问题可以像区分大小写和/或拼错目录名称/路径一样简单。我不相信没有交互/仿真就可以解决这个问题。

#3


0  

I've never seen zf create db-table.from-database work in any circumstances. However if you want to try the netbeans command that should work is -m default ('default' is the module, add -f for force overwrite) the resulting command will look like: zf create db-table.from-database -m default.

我从来没有在任何情况下看到zf create db-table.from-database工作。但是,如果要尝试运行的netbeans命令是-m default('default'是模块,添加-f for force overwrite),结果命令将如下所示:zf create db-table.from-database -m default 。

Personally I just use the zf create db-table command to create just the db-table models I need.

我个人只是使​​用zf create db-table命令来创建我需要的db-table模型。

This command would work zf create db-table users users -m admin -f where -m admin(the -m does seem to be required) is the module and -f indicates force over write. The first users is the name of the class (Application_Model_DbTable_Users, Users.php), the second users is the actual name of the database table.

这个命令可以工作zf create db-table users users -m admin -f其中-m admin(-m似乎需要)是模块,-f表示强制写入。第一个用户是类的名称(Application_Model_DbTable_Users,Users.php),第二个用户是数据库表的实际名称。

I don't know what you're expecting as far a model goes, what you're going to get is something very similar to:

我不知道你对模型的期望是什么,你将得到的东西非常类似于:

<?php

class Application_Model_DbTable_User extends Zend_Db_Table_Abstract
{
    protected $_name    = 'users';
}

This a very important class when using the Zend_Db component but if you're new to ZF it may be a little confusing.

这是使用Zend_Db组件时非常重要的一个类,但如果你是ZF的新手,可能会有点混乱。