In my module.php file, I want to pass multiple table names via TableGateway class in Zend Framework but I cannot find any documentation on it, other than it being limited to one table. The phpdoc for this (TableGateway) class says an array can be passed but again, I am not sure if it accepts more than one table.
for example in Module.php:
'Application\Model\LoginModel' => function($sm) {
$table_gateway = $sm->get('LoginService');
$table = new LoginModel($table_gateway);
return $table;
},
'LoginService' => function($sm) {
$db_adapter = $sm->get('Zend\Db\Adapter\Adapter');
$result_set_prototype = new ResultSet();
$result_set_prototype->setArrayObjectPrototype(new Login());
return new TableGateway(array('admins', 'members'), $db_adapter, null, $result_set_prototype);
}
Is it possible to do this and have multiple tables referenced or bound like this, or is it only designed to allow one table for each instance?
No it is not. Table Gateway object is intended to provide an object that represents a table in a database. Array
can be passed to the constructor, but if you pass it, you will get InvalidArgumentException
. Please check this code
Please look at again TableGateway
purposed on documentation here
https://framework.zend.com/manual/2.4/en/modules/zend.db.table-gateway.html