Re: Child model fields
Thanks for the reply. I have tried $this-Game-Score-create(); in my Games controller but the result is still the same as before. Here are the debug statements: 6 INSERT INTO `scores` (`player_id`,`player_points`,`player_finish`,`game_id`,`created`,`modified`) VALUES (374,'0',10,60,'2008-01-01 21:28:32','2008-01-01 21:28:32') 1 2 7 SELECT LAST_INSERT_ID() AS insertID 1 1 1 8 SELECT COUNT(id) AS count FROM `scores` WHERE `id` = 58 1 1 2 9 SELECT COUNT(id) AS count FROM `scores` WHERE `id` = 58 1 1 2 10 UPDATE `scores` SET `player_id` = 374,`player_points` = '0',`player_finish` = 10,`game_id` = 60,`modified` = '2008-01-01 21:28:32' WHERE `id` IN (58) As you can see, it is only pulling out one Score model from the page. On Jan 1, 2:05 am, soytuny [EMAIL PROTECTED] wrote: $this-create(); I think, and I've had a bit to drink, should be $this-Game-Score- create(); DaveM wrote: Hi all, I am trying to build a page that uses a parent model (Game) and child models (Score). Game has the following fields: id, game_number, and date. Score has the following fields: player_id, player_finish, player_points, and game_id. In my scenario, there should always be 10 Score(s) per Game. I'd like to have the player_id, player_finish, and player_points rendered on the page when the Add New Game link is clicked. I've defined my Score fields as follows: tr td1/td td?php echo $html-input('Score/player_id', array('size' = '4'))? /td td?php echo $html-input('Score/player_points', array('size' = '4','value' = $valueOne))? /?php echo $html-hidden('Score/player_finish', array('value' = '1')); ? /tr tr td2/td td?php echo $html-input('Score/player_id', array('size' = '4'))? /td td?php echo $html-input('Score/player_points', array('size' = '4','value' = $valueTwo))?/td ?php echo $html-hidden('Score/player_finish', array('value' = '2')); ? /tr I don't think this is correct. In the save, the Game array ($this- data['Game']) does not contain ANY of the score domains. The last Score model defined on my view is being saved. The manual says: These same basic techniques will work if you're saving multiple child models, just place those save() calls in a loop (and remember to clear the model information using Model::create()). I tried this code thinking it would save two Score models, but it simply inserts one record and then updates the same record: $gameID = $this-Game-getLastInsertId(); $this-data['Score']['game_id'] = $gameID; $this-Game-Score-save($this-data); $this-create(); $gameID = $this-Game-getLastInsertId(); $this-data['Score']['game_id'] = $gameID; $this-Game-Score-save($this-data); I'm stuck. Any thoughts would be awesome. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com 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 -~--~~~~--~~--~--~---
Child model fields
Hi all, I am trying to build a page that uses a parent model (Game) and child models (Score). Game has the following fields: id, game_number, and date. Score has the following fields: player_id, player_finish, player_points, and game_id. In my scenario, there should always be 10 Score(s) per Game. I'd like to have the player_id, player_finish, and player_points rendered on the page when the Add New Game link is clicked. I've defined my Score fields as follows: tr td1/td td?php echo $html-input('Score/player_id', array('size' = '4'))? /td td?php echo $html-input('Score/player_points', array('size' = '4','value' = $valueOne))? /?php echo $html-hidden('Score/player_finish', array('value' = '1')); ? /tr tr td2/td td?php echo $html-input('Score/player_id', array('size' = '4'))? /td td?php echo $html-input('Score/player_points', array('size' = '4','value' = $valueTwo))?/td ?php echo $html-hidden('Score/player_finish', array('value' = '2')); ? /tr I don't think this is correct. In the save, the Game array ($this- data['Game']) does not contain ANY of the score domains. The last Score model defined on my view is being saved. The manual says: These same basic techniques will work if you're saving multiple child models, just place those save() calls in a loop (and remember to clear the model information using Model::create()). I tried this code thinking it would save two Score models, but it simply inserts one record and then updates the same record: $gameID = $this-Game-getLastInsertId(); $this-data['Score']['game_id'] = $gameID; $this-Game-Score-save($this-data); $this-create(); $gameID = $this-Game-getLastInsertId(); $this-data['Score']['game_id'] = $gameID; $this-Game-Score-save($this-data); I'm stuck. Any thoughts would be awesome. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com 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 -~--~~~~--~~--~--~---
Multiple associations per model
Hi all, I'm struggling with designing the models for an application I'm building. Here is my database structure: players -- id -- name games -- id -- player_one_id -- player_two_id -- player_three_id -- player_four_id -- player_five_id Each game has five players. Any player can appear in multiple games, but not in the same game twice. How would I need to setup my model associations and how do I define the player_#_id fields in the game views? Thanks in advance! Dave --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com 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 -~--~~~~--~~--~--~---