请在下面找到Zend公司:从多个表中获取数据
module.php
public function getServiceConfig()
{
return array(
'factories' => array(
'Shopping\Model\ShopTable' => function($sm) {
$tableGateway = $sm->get('ShopTableGateway');
$table = new ShopCategoriesTable($tableGateway);
return $table;
},
'ShopTableGateway' => function ($sm) {
$dbAdapter = $sm->get('Zend\Db\Adapter\Adapter');
$resultSetPrototype = new ResultSet();
$resultSetPrototype->setArrayObjectPrototype(new ShopCategories());
return new TableGateway('shop_goods', $dbAdapter, null, $resultSetPrototype);
},
),
);
}
shoppingcontroller.php
public function getShopTable()
{
if (!$this->shopTable)
{
$sm = $this->getServiceLocator();
$this->shopTable = $sm->get('Shopping\Model\ShopTable');
}
return $this->shopTable;
}
我的代码,你可以在我的第一个代码见shop_categories
是我的数据库表,从中获取数据的iam,上面的代码工作正常。但现在我需要从其他表中取数据命名为shop_goods
如何配置module.php?
Hi duques,我的意思是说,我必须同时从两个表中提取数据... – Friend
在一个请求中? – Tounu
我想,加入查询? – Pierre