I'm new to Zend2, and want to combine two tablegateway objects
I have two tables: prices and sizes. Every price has multiple sizes. I want to join these tables into an array, so I can list the prices with the sizes in it.
For example:
array(
1 => array(
'price' => 45,
'description' => 'Lorem ipsum',
'sizes' => array(
1 => '16',
2 => '17',
3 => '20',
4 => '21'
)
),
2 => array(
'price' => 50,
'description' => 'Lorem ipsum',
'sizes' => array(
1 => '34',
2 => '12',
3 => '21',
4 => '50'
)
)
)
My PricesTable.php:
public function getPricesbyJewel($jewel)
{
$rowset = $this->tableGateway->select(array('jewelid' => $jewel));
return $rowset;
}
My SizesTable.php
public function getSizesbyPrice($price)
{
$rowset = $this->tableGateway->select(array('priceid' => $price));
return $rowset;
}
How I list the prices (so without the sizes in it)
$jewelPrices = array('jewelryPrices' => $this->getPricesTable()->getPricesbyJewel($jewel->id));
$jewelSizes = array('jewelrySizes' => $this->getSizesTable()->getSizesbyPrice($priceID);
How to list the sizes into the prices as an array of those tables in the controller?