Guest User

Untitled

a guest
Jan 22nd, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. $this->set("post", $this->Post->find("first", array("conditions" => array("Post.id" => $id), "contain" => array("User", "Project", "Project.Post" => array("id", "image", "title"), "Comment", "Comment.User" => array("id", "username", "mail"), "Comment.User.Post" => array("id", "image", "title")))));
  2. $this->set("neighbors", $this->Post->find("neighbors", array("field" => "id", "value" => $id)));
  3.  
  4. $post = $this->Post->find("first", ...); // this is your first find call, assign it to a var instead
  5.  
  6. $neighbors = $this->Post->find('neighbors', array(
  7. 'field' => 'id',
  8. 'value' => $id,
  9. 'conditions' => array(
  10. 'Post.project_id' => $post['Post']['project_id'],
  11. ),
  12. ));
  13. $this->set(compact('post', 'neighbors'));
Add Comment
Please, Sign In to add comment