如何创建其他实体设置的实体?我使用mapper / hydrator和hydrator srategy就像这个例子。
class AccountMapperFactory implements FactoryInterface
{
public function createService(ServiceLocatorInterface $serviceLocator)
{
$dbAdapter = $serviceLocator->get('zfcuser_zend_db_adapter');
$entity = new Account();
$mapper = new AccountMapper();
$mapper->setDbAdapter($dbAdapter);
$hydrator = new AccountHydrator();
$hydrator->addStrategy('orderId', new OrderStrategy());
$mapper
->setEntityPrototype($entity)
->setHydrator($hydrator)
->setTableName($mapper->getTableName());
return $mapper;
}
}
然后我可以这样称呼它
$this->AccountMapperFactory()->findById(1);
我使用空订单实体获取帐户实体,如何创建填充对象的方式呢?
谢谢,
答案 0 :(得分:0)
对于正在寻找答案的人,我发现了这两个参考文献。
retrieving-every-field-of-a-database-row-as-object-in-zend-framework-2