简体   繁体   中英

Getting data from joins in Zend 2

I have a join in Zend. In my model I have

$select->join('properties', 'properties.OID = advertised_properties.TenancyProperty', array(), 'left');

TenancyProperty is the foreign key which is OID in the properties table.

In my view I can access rows from advertised_properties like this (using pagination)

foreach ($this->paginator as $rentals) : ?>
.....
<?php echo $this->escapeHtml($rentals->ColumnInAdvertised_Properties);?>

but if I try and access rows from the joined table (properties) using

<?php echo $this->escapeHtml($rentals->ColumnInProperties);?>

I do not get the data. Can somebody please explain what I am doing wrong and why I do not get this data?

I worked it out! I was missing the values I need in the array like this

$select->join('properties', 'properties.OID = advertised_properties.TenancyProperty', array('Column1fromTable' , 'Column2fromTable'), 'left');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM