Re: HABTM retrieving help
You would read the Cake Manual section on pagination which answers all your questions. http://book.cakephp.org/view/164/pagination On Jan 3, 10:30 pm, gearvOsh mileswjohn...@gmail.com wrote: 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: HABTM retrieving help
I know how to pagination, but. I would like to do the pagination from the Team model, but the data I need to access is in the TeamsPlayer model. Understand? On Jan 4, 8:01 am, Smelly_Eddie ollit...@gmail.com wrote: You would read the Cake Manual section on pagination which answers all your questions.http://book.cakephp.org/view/164/pagination On Jan 3, 10:30 pm, gearvOsh mileswjohn...@gmail.com wrote: 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: HABTM retrieving help
If I understood correctly you're trying to paginate realated HABTM data based on some condition on the join table? Have a look at http://cakebaker.42dh.com/2007/10/17/pagination-of-data-from-a-habtm-relationship/ and http://www.cricava.com/blogs/index.php?blog=6title=modelizing_habtm_join_tables_in_cakephp_more=1c=1tb=1pb=1 Just a side note: if you want to follow cake's conventions, the join table should actually be named players_teams. gearvOsh wrote: I know how to pagination, but. I would like to do the pagination from the Team model, but the data I need to access is in the TeamsPlayer model. Understand? On Jan 4, 8:01 am, Smelly_Eddie ollit...@gmail.com wrote: You would read the Cake Manual section on pagination which answers all your questions.http://book.cakephp.org/view/164/pagination On Jan 3, 10:30 pm, gearvOsh mileswjohn...@gmail.com wrote: 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---