Zend_Db_Table_Abstract $_name 不工作
我遇到了有关更改默认表名称的问题
class Application_Model_DbTable_Game extends Zend_Db_Table_Abstract
{
protected $_name = 'games';
错误:
消息:SQLSTATE [42S02]:未找到基表或视图:1146表'gamenomad_dev.game'不存在
帮助我...它应该很简单!
*编辑 这里的问题是 Zend Framework 应该检测到从默认的“game”到“games”的更改表名称。
I encountered a problem regarding changing default table name
class Application_Model_DbTable_Game extends Zend_Db_Table_Abstract
{
protected $_name = 'games';
Error:
Message: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'gamenomad_dev.game' doesn't exist
Help me... it's supposed to be simple!
*EDIT
The problem here is that Zend Framework is supposed to detect the changed table name from the default 'game' into 'games'.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在 ZF 中,您必须对数据库表进行硬编码才能建模。它不扫描数据库更改。有两种方法:
使用表名创建类
如果要使用 ZF 的默认路径,则应将 DBTable 模型放入
application/models/dbtable
目录中,并将类命名为Application_Model_DbTable_Game
- 然后 ZF 知道它必须查找game
表使用任意名称创建类,
例如
ExtraGameTable
并设置其参数显示表名称:如文档中所述: http://framework.zend.com/手册/en/zend.db.table.html
您可以尝试将其与某些配置文件结合起来并从那里加载表名称,但 ZF 仍然不知道有关底层数据库更改的任何信息。
In ZF you have to hardcode your database table to model. It doesn't scan for database changes. You have two ways:
Create class with table name
If you want to use ZF's default paths, you should put DBTable model into
application/models/dbtable
directory and name your class likeApplication_Model_DbTable_Game
- then ZF knows it has to look forgame
tableCreate class with any name
e.g.
ExtraGameTable
and set its parameters to show table name:As stated in documentation: http://framework.zend.com/manual/en/zend.db.table.html
You may try to combine it with some configuration file and load table names from there, but still - ZF won't know anything about underlying database changes.
显示问题的实际行和堆栈跟踪,也许您正在以不读取实际表名的方式生成查询。
Show the actual line and stacktrace to your problem, maybe you are generating your query in a way it doesn't read the actual table name.