Saturday, January 3, 2009

HABTM retrieving help

Heres my tables and relations:

Team
Team->belongsTo: Country, State
Team->hasAndBelongsToMany: User (the players on a team, table =
teams_players)

Team:
CREATE TABLE IF NOT EXISTS `teams` (
`id` int(10) NOT NULL auto_increment,
`status` enum('approved','pending') NOT NULL default 'pending',
`name` varchar(50) NOT NULL,
`tag` varchar(10) NOT NULL,
`urlName` varchar(30) NOT NULL,
`website` varchar(50) NOT NULL,
`irc` varchar(20) NOT NULL,
`about` varchar(255) NOT NULL,
`servers` varchar(100) NOT NULL,
`logo` varchar(100) NOT NULL,
`createDate` int(10) unsigned NOT NULL default '0',
`state_id` int(10) unsigned NOT NULL default '0',
`country_id` int(10) unsigned NOT NULL default '0',
`created` datetime default NULL,
`modified` datetime default NULL,
PRIMARY KEY (`id`),
KEY `state_id` (`state_id`),
KEY `country_id` (`country_id`)
)

TeamsPlayer
CREATE TABLE IF NOT EXISTS `teams_players` (
`id` int(11) NOT NULL auto_increment,
`team_id` int(10) unsigned NOT NULL,
`user_id` int(10) unsigned NOT NULL,
`role` enum('leader','captain','member') NOT NULL default 'member',
`status` enum('approved','pending') NOT NULL default 'pending',
`joinDate` int(10) NOT NULL,
PRIMARY KEY (`id`),
KEY `team_id` (`team_id`),
KEY `user_id` (`user_id`)
)


Ok if I do a basic Team->find() all the data is returned correctly.

Now the problem im running into is how do I grab all teams that I am
part of, and paginate it at the same time? Since the user_id values is
in TeamsPlayer, im getting confused on this. Any help would be
appreciated.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: