Re: Need a little help with HABTM joins
nothing happens. users cannot de-associate Articles and Pieces So within your article/edit action what find calls are you making to fetch the article and all pieces (related or not)? Paul. -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Re: Need a little help with HABTM joins
So by default you are associating all Articles to Pieces? I really suspect you're going about things in the wrong way here. Paul. On Nov 8, 10:04 am, Ernesto e.fanz...@gmail.com wrote: Thanks for the effort, i solved this way: - in both articles/add and pieces/add users can enter just code and description, no related model data - after a successfull add() both Article and Piece models add every possible combination between them and the other model. The app then redirects diretcly to the edit action - in both edit actions there's a simple hasMany form where the users can modify the ArticlePieces data. -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Re: Need a little help with HABTM joins
What happens if when the edit form first shows you unassociate all pieces, what happens the next time you load the edit form? I suspect the way you've done it you will get no pieces again. As mentioned earlier you should be using: $this-Article-Piece-find('all'); or $this-Article-Piece- find('list'); if populating an array to then be used as options in a form. HTH, Paul On Nov 9, 9:11 am, WebbedIT p...@webbedit.co.uk wrote: So by default you are associating all Articles to Pieces? I really suspect you're going about things in the wrong way here. Paul. On Nov 8, 10:04 am, Ernesto e.fanz...@gmail.com wrote: Thanks for the effort, i solved this way: - in both articles/add and pieces/add users can enter just code and description, no related model data - after a successfull add() both Article and Piece models add every possible combination between them and the other model. The app then redirects diretcly to the edit action - in both edit actions there's a simple hasMany form where the users can modify the ArticlePieces data. -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Re: Need a little help with HABTM joins
nothing happens. users cannot de-associate Articles and Pieces -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Re: Need a little help with HABTM joins
How can i load an article, with ALL the pieces, even if they haven't a relationship, using Cake's find function? You can't do this with one find query, this is not a limitation of CakePHP you simply can't do one database call that will find one article and all pieces related or not. This will not solve my issue. i want to load all the Pieces, even if they're not related to the Article Model $this-Piece-find('all'); or $this-Piece-find('list'); if populating an array to then be used as options in a form. @Giorgio: Why should the tables be linked by HABTM? How do you then accurately save and work with the extra fields Ernesto wants in that table? HABTM is just a convenience wrapper for the associations Ernesto laid out in his original post, as soon as you want to start doing extra stuff with the join table it;s a good idea to modelise it. HTH, Paul. -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Re: Need a little help with HABTM joins
Thanks for the effort, i solved this way: - in both articles/add and pieces/add users can enter just code and description, no related model data - after a successfull add() both Article and Piece models add every possible combination between them and the other model. The app then redirects diretcly to the edit action - in both edit actions there's a simple hasMany form where the users can modify the ArticlePieces data. -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Need a little help with HABTM joins
Hi all. i have 2 models, Articles and Pieces. They should've been linked by a HABTM but i need to save some additional fields in the join table so i made 2x hasMany. Here's my situation: Article hasMany ArticlePiece Piece hasMany ArticlePiece ArticlePiece belongsTo Article ArticlePiece belongsTo Piece How can i load an article, with ALL the pieces, even if they haven't a relationship, using Cake's find function? i need an array like this: Array ( [Article] = Array ( [id] = 1 [code] = XY [description] = rotflrotflrotfl ) [ArticlePiece] = Array ( [0] = Array ( [id] = 1 [article_id] = 1 [piece_id] = 1 [quantity] = 10.00 [cost_each] = 5.00 ) [1] = Array ( [id] = 2 [article_id] = 1 [piece_id] = 2 [quantity] = 3.00 [cost_each] = 15.00 ) [2] = Array ( [id] = 3 [article_id] = 1 [piece_id] = 3 [quantity] = //no cost, no quantity = not related [cost_each] = //no cost, no quantity = not related ) ) ) Sorry for my bad english -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Re: Need a little help with HABTM joins
I'd use a condition... or use $this-Article-ArticlePiece-findById(1); -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Re: Need a little help with HABTM joins
this will load only related models :\ -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Re: Need a little help with HABTM joins
Are u italian? Anyway, if I understood: Recipe HABTM Tag | *recipes_tags.*id, *recipes_tags.*recipe_id, * recipes_tags.*tag_id in ur case: *In the Model of Article* Article HABTM Piece | *article_piece*.id, *article_piece*.article_id, * article_piece*.piece_id, (*article_piece.**) About additional fields, don't worry. Just to remember, when u save, to put a correct array. -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Re: Need a little help with HABTM joins
$this-Article-find('first', array( 'conditions'=array('Article.id'=$id), 'contain'=array('ArticlePiece'='Piece'), )); HTH, Paul. On Nov 7, 12:41 pm, Ernesto e.fanz...@gmail.com wrote: this will load only related models :\ -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Re: Need a little help with HABTM joins
Hi. thx for the answer. This will not solve my issue. i want to load all the Pieces, even if they're not related to the Article Model -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Re: Need a little help with HABTM joins
ENG: Thanks for the effort but this isn't my problem ITA: Grazie del tentativo ma non é quello il mio problema :) -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Re: Need a little help with HABTM joins
They should've been linked by a HABTM but i need to save some additional fields in the join table so i made 2x hasMany. ITA: Article e Piece dovrebbero essere linkati via HABTM, ma vuoi salvare altri campi addizionali nella Tabella ArticlePiece. ITA: ma la tabella ArticlePiece può avere tutti i campi che tu desideri, importante è che imposti correttamente i campi legati ad ArticlePiece.Article_id e ArticlePiece.Piece_id... ITA: Non capisco, qual è invece il tuo array di risposta che ti da $this-ArticlePiece-findBy*ArticleId*($id) reale?? Posta un esempio di ciò che ricevi! ;) ENG: Article and Piece should be linked by HABTM, but u want saving other additional fields on ArticlePiece's table. ENG: the table ArticlePiece could have every fields in more that u desire. It's important setting in a right way only ArticlePiece.Article_id and ArticlePiece.Piece_id ENG: post an example of ur actual array.. please.. :) -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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