# Problem in retriveing data using cakephp 4

**URL:** <https://discourse.cakephp.org/t/problem-in-retriveing-data-using-cakephp-4/8493>\
**Category:** Need Help\
**Created:** [October 11, 2020, 5:02pm UTC](https://discourse.cakephp.org/t/problem-in-retriveing-data-using-cakephp-4/8493 "2020-10-11T17:02:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jamal-alnaeb](https://avatars.discourse-cdn.com/v4/letter/j/ed655f/32.png) [@jamal-alnaeb](https://discourse.cakephp.org/u/jamal-alnaeb)\
**Post date:** [October 11, 2020, 5:02pm UTC](https://discourse.cakephp.org/t/problem-in-retriveing-data-using-cakephp-4/8493/1 "2020-10-11T17:02:34Z")

</div>

Good evening to all.  
I am newly using a new version of CakePHP strawberry.

I have two tables (Categories and Products).  
The categories has many prodoucts and products belongs to one category  
I define the relation betwwen them like this  
$this-\>belongsTo(‘Categories’);  
$this-\>hasMany(‘Products’)-\>setForeignKey(‘category\_id’)-\>setDependent(true);

The question I need to view all categories name inside the index of products like this  
product id / product name / category name

in previous version that i use the behviours {Containable}  
in this version i use like this  
$this-\>paginate = [

```
        'contain' => ['Categories'],

    ];

```

and I use to like this

$this-\>Products-\>find(‘all’)-\>leftJoinWith(‘Categories’);  
but unfortunetly no way works with me

Any suggestions for that .Thank you

---

<div class="post-metadata">

**Author:** ![Zuluru](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/zuluru/32/1230_2.png) [@Zuluru](https://discourse.cakephp.org/u/Zuluru)\
**Post date:** [October 11, 2020, 5:57pm UTC](https://discourse.cakephp.org/t/problem-in-retriveing-data-using-cakephp-4/8493/2 "2020-10-11T17:57:39Z")

</div>

What version were you using before? And what does “no way works” mean? Do you get no products? Products with no categories? Duplicated products? Also, please expand your code around the “find” you’re using to show a bit more context about what happens with the result of that call.
