Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2014
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. SELECT `Post`.`id`, `Post`.`author`, `Post`.`title`, `Post`.`content`, `Post`.`description`, `Post`.`status`,
  2. `Post`.`name`, `Post`.`type`, `Post`.`date`, `Post`.`modified`, `Post`.`img`,
  3. `Authors`.`username`, `Authors`.`id`
  4. FROM `myblog`.`posts` AS `Post`
  5. LEFT JOIN `myblog`.`users` AS `Authors` ON (`Authors`.`id` = `Post`.`author`)
  6. WHERE `Post`.`type` = 'post'
  7. ORDER BY `Post`.`date` desc
  8. LIMIT 5
  9.  
  10. (`Authors`.`id` = `Post`.`author`)
  11.  
  12. ON (`Authors`.`id` = `Post.author`)
  13.  
  14. public $hasOne = array(
  15. 'Authors' => array(
  16. 'className' => 'User',
  17. 'foreignKey' =>'id',
  18. 'fields' => array('username','id'),
  19. 'conditions'=>array('Authors.id'=>'Post.author')
  20. )
  21. );
  22.  
  23. public $paginate = array(
  24. 'Post' => array(
  25. 'paramType' => 'querystring',
  26. 'limit' => 5,
  27. 'conditions'=> array('Post.type'=>'post'),
  28. 'order' => array('Post.date'=>'desc')
  29. )
  30. );
  31.  
  32. ...
  33. ...
  34. ...
  35.  
  36. public function index() {
  37.  
  38. $this->Paginator->settings = $this->paginate;
  39.  
  40. $data = $this->Paginator->paginate('Post');
  41.  
  42. $this->set('posts',$data);
  43. }
  44.  
  45. public $hasMany = array('Post');
  46.  
  47. public $belongsTo = array('User');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement