【问题标题】:ZF2 Database table no instance returnedZF2 数据库表没有返回实例
【发布时间】:2015-03-15 01:15:19
【问题描述】:

我在 ZF2 中遇到了我的数据库模型的问题,我必须在应用程序中触摸一些东西,因为我确信它以前可以工作。

想知道是否有人可以通过我收到的以下错误消息读出问题。

如果需要更多错误信息,我可以用堆栈更新这个问题:)

 Zend\ServiceManager\Exception\ServiceNotCreatedException

 File:
 /home/xxxxx/domains/xxxx.nl/vendor/zendframework/zendframework/library/Zend/ServiceManager/ServiceManager.php:909

 Message:
 An exception was raised while creating "Application\Model\CelebrityTable"; no instance returned



 **Previous exceptions:**
 Zend\Db\TableGateway\Exception\RuntimeException

 File:
 /home/xxxx/domains/xxxx/vendor/zendframework/zendframework/library/Zend/Db/TableGateway/AbstractTableGateway.php:105

 Message:
 This table object does not have a valid table set.

【问题讨论】:

    标签: php exception zend-framework2


    【解决方案1】:

    例外情况说明了您需要了解的大部分内容。

    File:
     /home/xxxx/domains/xxxx/vendor/zendframework/zendframework/library/Zend/Db/TableGateway/AbstractTableGateway.php:105
    
     Message:
     This table object does not have a valid table set.
    

    我去了Zend/Db/TableGateway/AbstractTableGateway.php:105,下面这段代码就在那里;

    if (!is_string($this->table) && !$this->table instanceof TableIdentifier && !is_array($this->table)) {
        throw new Exception\RuntimeException('This table object does not have a valid table set.');
    }
    

    所以你的例外意味着。 $this->table 不是 stringarrayinstanceof Zend\Db\Sql\TableIdentifier

    所以你可能没有摆好桌子。

    现在我从未使用过AbstractTableGateway,所以不确定如何在正确的上下文中使用它。但我没有看到 setTable 或类似 setOptions 的东西。

    因此,除非您可以展示您的 TableGateWay 实现,否则据我所知。

    注意,我看的是zf2.3.3

    【讨论】:

    • 完美!是的,我写错了 $this->_table 而不是 $this->table .... 非常感谢
    猜你喜欢
    • 2017-07-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-04-28
    • 1970-01-01
    相关资源
    最近更新 更多