0
想创建的Zend \ DB的一个实例\ TableGateway序与数据库进行交互,但我总是得到这个错误:与Zend DB TableGateway TableGateway工作
Catchable fatal error: Argument 1 passed to Question\Model \QuestionsTable::__construct() must be an instance of Zend\Db\TableGateway\TableGateway, none given.
here is how am trying to implement it:...
namespace Question\Model;
use Zend\Db\TableGateway\TableGateway;
class QuestionsTable
{
public $usr_id;
public $title;
public $description;
public $status;
protected $tableGateway;
public function __construct(TableGateway $tableGateway)
{
$this->tableGateway = $tableGateway;
}
我猜想有一个与我如何在服务管理器实现它的错误:
return array(
'factories' => array(
'Question\Model\QuestionsTable' => function($sm) {
$tableGateway = $sm->get('QuestionsTableGateway');
$table = new QuestionsTable($tableGateway);
return $table;
},
'QuestionsTableGateway' => function ($sm) {
$dbAdapter = $sm->get('Zend\Db\Adapter\Adapter');
$resultSetPrototype = new ResultSet();
//$resultSetPrototype->setArrayObjectPrototype(new QuestionsTable);
return new TableGateway('codepro', $dbAdapter, null, $resultSetPrototype);}
));
please help on how to go about the servicce manager..Thanks in advance