Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT `Post`.`id`, `Post`.`author`, `Post`.`title`, `Post`.`content`, `Post`.`description`, `Post`.`status`,
- `Post`.`name`, `Post`.`type`, `Post`.`date`, `Post`.`modified`, `Post`.`img`,
- `Authors`.`username`, `Authors`.`id`
- FROM `myblog`.`posts` AS `Post`
- LEFT JOIN `myblog`.`users` AS `Authors` ON (`Authors`.`id` = `Post`.`author`)
- WHERE `Post`.`type` = 'post'
- ORDER BY `Post`.`date` desc
- LIMIT 5
- (`Authors`.`id` = `Post`.`author`)
- ON (`Authors`.`id` = `Post.author`)
- public $hasOne = array(
- 'Authors' => array(
- 'className' => 'User',
- 'foreignKey' =>'id',
- 'fields' => array('username','id'),
- 'conditions'=>array('Authors.id'=>'Post.author')
- )
- );
- public $paginate = array(
- 'Post' => array(
- 'paramType' => 'querystring',
- 'limit' => 5,
- 'conditions'=> array('Post.type'=>'post'),
- 'order' => array('Post.date'=>'desc')
- )
- );
- ...
- ...
- ...
- public function index() {
- $this->Paginator->settings = $this->paginate;
- $data = $this->Paginator->paginate('Post');
- $this->set('posts',$data);
- }
- public $hasMany = array('Post');
- public $belongsTo = array('User');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement