简体   繁体   中英

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:

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

If I test this using Phpunit I get the error

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 ?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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