1
나는 Zend\Db\TableGateway
의 인스턴스를 만들려고 시도했지만 올바르게 만들 수 없습니다. 이것은 내가 내 module.php
에있는 것입니다 :서비스 관리자를 사용하여 Zend Db TableGateway의 인스턴스 만들기
use Question\Model\QuestionsTable;
use Zend\Db\ResultSet\ResultSet;
use Zend\Db\TableGateway\TableGateway;
//other statements and then getServiceConfig()
public function getServiceConfig()
{
return array(
'factories' => array(
'Question\Model\QuestionsTable' => function($sm) {
$tableGateway = $sm->get('AlbumTableGateway');
$table = new QuestionsTable($tableGateway);
return $table;
},
'AlbumTableGateway' => function ($sm) {
$dbAdapter = $sm->get('Zend\Db\Adapter\Adapter');
$resultSetPrototype = new ResultSet();
$resultSetPrototype->setArrayObjectPrototype(new QuestionsTable());
return new TableGateway('questions', $dbAdapter, null, $resultSetPrototype);
},
),
);
}
이 내 QuestionsTable.php
파일입니다
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;
}
}
그리고 이것이 내가 점점 오전 오류입니다 : 사전에 Catchable fatal error: Argument 1 passed to Question\Model\QuestionsTable::__construct() must be an instance of Zend\Db\TableGateway\TableGateway,none given.
감사합니다.
어떤 앨범 TUTO에서 Database and models에 설명 된대로 그것을 같은 방식으로 작업을 수행 할 수 있습니다 Zend Dev는이 부분에 약간의 빛을 비춰 줘. 내 모든 것이 괜찮다고 생각하기 때문에. – Joss