# How to get property of associated table?

**URL:** <https://discourse.cakephp.org/t/how-to-get-property-of-associated-table/1475>\
**Category:** Need Help\
**Created:** [November 7, 2016, 10:06pm UTC](https://discourse.cakephp.org/t/how-to-get-property-of-associated-table/1475 "2016-11-07T22:06:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![chief-cook](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/chief-cook/32/479_2.png) [@chief-cook](https://discourse.cakephp.org/u/chief-cook)\
**Post date:** [November 7, 2016, 10:06pm UTC](https://discourse.cakephp.org/t/how-to-get-property-of-associated-table/1475/1 "2016-11-07T22:06:45Z")

</div>

hey there,  
very basic question but I’m kind of stuck with the syntax here:  
I have an entity query. The entity is associated to another table which has a ‘name’ property? (many to many association)

My $query looks like this when I debug it:  
/plugins/MailCalculator/src/Controller/PostalServicesController.php (line 140)  
object(MailCalculator\Model\Entity\PostalService) {

```
    'id' => (int) 1,
    'carrier' => 'Deutsche Post'
...

    },
    'modified' => null,
    '_matchingData' => [
        'Insurances' => object(MailCalculator\Model\Entity\Insurance) {

            'id' => (int) 2,
            'name' => 'Wert',
            'price' => (float) 4.3,
...

```

basically the question is, how do I get the values out from the \_\_matchingData array?

I thought the syntax for it should be something like:  
$var = $query-\>insurance-\>name or $var = $query-\>insurances[‘name’] but both things debugged give me ‘null’

thanks in advance, Rich

---

<div class="post-metadata">

**Author:** ![rrd](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/rrd/32/113_2.png) [@rrd](https://discourse.cakephp.org/u/rrd)\
**Post date:** [November 9, 2016, 3:00pm UTC](https://discourse.cakephp.org/t/how-to-get-property-of-associated-table/1475/2 "2016-11-09T15:00:48Z")

</div>

after running the query you can access it as $result[’\_matchingData’][‘Insurances’]-\>name

---

<div class="post-metadata">

**Author:** ![chief-cook](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/chief-cook/32/479_2.png) [@chief-cook](https://discourse.cakephp.org/u/chief-cook)\
**Post date:** [November 10, 2016, 7:13pm UTC](https://discourse.cakephp.org/t/how-to-get-property-of-associated-table/1475/3 "2016-11-10T19:13:43Z")

</div>

oh man, tried this one as well but missed the `' '` for the \_matchingData…

thanks a lot!
