Hi i'd like to know what i need to do and in what model, to be able to
use this SQL query
SELECT t.id, t.subject FROM topics AS t INNER JOIN forums AS f ON
f.id=t.forum_id LEFT JOIN forum_perms AS fp ON (fp.forum_id=f.id AND
fp.group_id='xxx') WHERE (fp.read_forum IS NULL OR fp.read_forum=1)
AND t.moved_to IS NULL ORDER BY t.last_post DESC LIMIT 10
actually this SQL Query :
SELECT `Post`.`id`, `Post`.`poster`, `Post`.`poster_id`,
`Post`.`poster_ip`, `Post`.`poster_email`, `Post`.`message`,
`Post`.`hide_smilies`, `Post`.`posted`, `Post`.`edited`,
`Post`.`edited_by`, `Post`.`topic_id`, `Topic`.`id`, `Topic`.`poster`,
`Topic`.`subject`, `Topic`.`posted`, `Topic`.`last_post`,
`Topic`.`last_post_id`, `Topic`.`last_poster`, `Topic`.`num_views`,
`Topic`.`num_replies`, `Topic`.`closed`, `Topic`.`sticky`,
`Topic`.`moved_to`, `Topic`.`forum_id` FROM `posts` AS `Post` LEFT
JOIN `topics` AS `Topic` ON (`Post`.`topic_id` = `Topic`.`id`) WHERE 1
= 1 ORDER BY `last_post` desc LIMIT 10
is produce when i do in my element :
$pt_active_topics = $this->requestAction('posts/index/sort:last_post/
direction:desc/limit:10');
here are my models :
<?php
class Post extends AppModel {
var $name = 'Post';
//The Associations below have been created with all possible keys,
those that are not needed can be removed
var $belongsTo = array(
'Topic' => array('className' => 'Topic',
'foreignKey' =>
'topic_id',
'conditions' =>
'',
'fields' => '',
'order' => '',
'counterCache'
=> ''),
);
}
<?php
class Topic extends AppModel {
var $name = 'Topic';
//The Associations below have been created with all possible keys,
those that are not needed can be removed
var $belongsTo = array(
'Forum' => array('className' => 'Forum',
'foreignKey' =>
'forum_id',
'conditions' =>
'',
'fields' => '',
'order' => '',
'counterCache'
=> ''),
);
var $hasMany = array(
'Post' => array('className' => 'Post',
'foreignKey' =>
'topic_id',
'conditions' =>
'',
'fields' => '',
'order' => '',
'dependent' =>
''),
);
}
<?php
class Forum extends AppModel {
var $name = 'Forum';
//The Associations below have been created with all possible keys,
those that are not needed can be removed
var $hasMany = array(
'ForumPerm' => array('className' => 'ForumPerm',
'foreignKey' =>
'forum_id',
'conditions' =>
'',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'dependent' =>
'',
'exclusive' =>
'',
'finderQuery'
=> '',
'counterQuery'
=> ''),
'Topic' => array('className' => 'Topic',
'foreignKey' =>
'forum_id',
'conditions' =>
'',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'dependent' =>
'',
'exclusive' =>
'',
'finderQuery'
=> '',
'counterQuery'
=> ''),
);
}
?>
<?php
class ForumPerm extends AppModel {
var $name = 'ForumPerm';
var $primaryKey = 'group_id,forum_id';
//The Associations below have been created with all possible keys,
those that are not needed can be removed
var $belongsTo = array(
'Group' => array('className' => 'Group',
'foreignKey' =>
'group_id',
'conditions' =>
'',
'fields' => '',
'order' => '',
'counterCache'
=> ''),
'Forum' => array('className' => 'Forum',
'foreignKey' =>
'forum_id',
'conditions' =>
'',
'fields' => '',
'order' => '',
'counterCache'
=> ''),
);
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---