Zend or I say this whole framework concept is new for me. Some examples are based on tablegateway format, in which you define name of table related to that controller in Module.php.
/* 'MYMODULE\Model\CompanyTable' => function($sm) {
$tableGateway = $sm->get('CompanyTableGateway');
$table = new CompanyTable($tableGateway);
return $table;
},
'CompanyTableGateway' => function ($sm) {
$dbAdapter = $sm->get('Zend\Db\Adapter\Adapter');
$resultSetPrototype = new ResultSet();
$resultSetPrototype->setArrayObjectPrototype(new Company());
return new TableGateway('rs_company', $dbAdapter, null, $resultSetPrototype);
},*/
And in other example there is only 3 lines of code in Module.php telling about adapter and then intializing through __constuct()
'MYMODULE\Model\CompanyTable' => function($sm) {
$dbAdapter = $sm->get('Zend\Db\Adapter\Adapter');
$table = new CompanyTable($dbAdapter);
return $table;
},
and in class __construc()
public function __construct(Adapter $adapter) {
$this->adapter = $adapter;
$this->resultSetPrototype = new ResultSet();
$this->resultSetPrototype->setArrayObjectPrototype(new Company());
$this->initialize();
}
What I can't understand is How to choose between both of them.