简体   繁体   English

Zend Framework 2 TableGateway getAdapter需要接口

[英]Zend Framework 2 TableGateway getAdapter needs Interface

Hi I am new to Zend Framework 2 and I am having a problem with this line of code: 嗨,我是Zend Framework 2的新手,这行代码有问题:

$sql = new Sql($this->tableGateway->getAdapter());

If I test this using Phpunit I get the error 如果我使用Phpunit对此进行测试,则会收到错误消息

Argument 1 passed to Zend\Db\Sql\Sql::__construct() must implement interface 
Zend\Db\Adapter\AdapterInterface, null given, called in C:\xampp\htdocs\zend2

Check if adapter is set. 检查是否设置了适配器。

var_dump(get_class($this->tableGateway->getAdapter()));

Also you how do you declare $this->tableGateway ? 另外,您如何声明$this->tableGateway

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM