Can you help me reproduce this?
I have this repository here:
https://github.com/ralphschindler/Zend_Db-Examples
That has a database already setup.
I'd like to get to the bottom of that error you have there. I've used
TableGateway to produce entity objects without problem, so I'd need to
see the code you are trying to use to see why its not possible for you.
-ralph
On 12/6/12 9:42 AM, Ralf Eggert wrote:
Hi Matthew,
thanks for your reply. Unfortunately, I can not get it to work.
It actually _is_ supported. The way to make it happen is to inject a
HydratingResultSet into the table gateway object; this object will
then be used when results are returned. The HydratingResultSet allows
you to specify both a hydrator as well as a prototype object to use
when hydrating. I've used this combination several times to create a
"poor man's mapper".
As an example:
https://github.com/weierophinney/PhlyPeep/blob/master/src/PhlyPeep/Model/PeepTable.php
-- this class uses the HydratingResultSet with the ArraySerializable
hydrator, and a custom entity, PhlyPeep. When I select rows using that
table gateway, I now get a result set that returns PhlyPeep objects as
I iterate over it. (I also built in pagination into that TDG
extension.)
I looked at your example, but did not see that you use the
RowGatewayFeature in that table. When I pass the HydratingResultSet to
the TableGateway and the RowGatewayFeature I get a fatal error
----------------------------------------------------------------------
Fatal error: Uncaught exception
'Zend\Db\TableGateway\Exception\RuntimeException' with message 'This
feature Zend\Db\TableGateway\Feature\RowGatewayFeature expects the
ResultSet to be an instance of Zend\Db\ResultSet\ResultSet' in
/home/devhost/project/vendor/zendframework/zendframework/library/Zend/Db/TableGateway/Feature/RowGatewayFeature.php:42
----------------------------------------------------------------------
So the combination of TableGateway, RowGateway and custom Entity classes
does not seem to work.
----------------------------------------------------------------------
$db = new Adapter(array(
'driver' => 'Pdo_Sqlite',
'database' => APPLICATION_ROOT . '/data/db/pizza.sqlite3.db',
));
$resultSet = new HydratingResultSet(
new ReflectionHydrator(), new ToppingEntity()
);
$rowGatewayFeature = new RowGatewayFeature('id');
$toppingsTable = new TableGateway(
'toppings', $db, $rowGatewayFeature, $resultSet
);
$rows = $toppingsTable->select(array('costs' => 1.5));
----------------------------------------------------------------------
Regards,
Ralf
--
List: fw-general@lists.zend.com
Info: http://framework.zend.com/archives
Unsubscribe: fw-general-unsubscr...@lists.zend.com