0

I am using cakephp v.3.2. Now I am facing some problem my query. Please check below my json record -

{
    "id": 22,
    "title": "",
    "description": "vfdvfdvffd",
    "type": 0,
    "allow_comment": 0,
    "owner_id": 35,
    "created": "2016-04-11T12:02:29+0000",
    "status": 1,
    "post_images": []
 },

I have two tables one is posts and another is post_images I am using hasmany. But I want to show all the records which is no post_images.

I am trying following code but not working. Please see my code -

$get_post_list_for_photo_tab = $this->Posts->find('all')
           ->where([
                  'Posts.owner_id' =>$query_for_school_admin['id'],
                  'post_images !='=>''])
           ->contain(['PostImages'])
           ->order(['created' => 'DESC'])->toArray();

Please help me.

Chinmay235
  • 3,236
  • 8
  • 62
  • 93

1 Answers1

1

Two possibile solutions:

Community
  • 1
  • 1
floriank
  • 25,546
  • 9
  • 42
  • 66