CakePHP pagination with HABTM models

前端 未结 3 1647
眼角桃花
眼角桃花 2020-12-11 09:31

I\'m having some problems with creating pagination with a HABTM relationship. First, the tables and relationships:

requests (id, to_location_id, from_locatio         


        
3条回答
  •  执念已碎
    2020-12-11 10:02

    I've been able to get it working somewhat, but the solution doesn't feel very cakey at all.

    $items = $this->paginate(
        $this->Request->ToLocation->Item,
        array(
            "Item.id IN ("
            . "SELECT item_id FROM items_locations "
            . "WHERE location_id = " . $locationId
            . ")"
        )
    );
    

提交回复
热议问题