Re: Chaining together objects
Sorry I wan't explicit in my description. My tables are named as such. I just hastily typed in my description of the problem without regard to those details. On Jun 5, 5:31 am, OptimusS wrote: > Hi i am new in cakephp but i think your problem is with cake's naming > conventions. Your tables should be named "comments" and "docs" > > On Fri, Jun 5, 2009 at 3:28 AM, Greg Baker wrote: > > > I have the following scenario.. A user can upload a document, that > > document can be commented on, then a new document can be uploaded and > > 'attached' to that comment. This gives a chain of objects kind of > > like this: > > > doc-comment-doc-comment-doc-comment > > > Where the cardinality of associations is 0..1 for each association. > > In my tables I have the fields doc (comment_id) and a field in comment > > (doc_id). > > I have tried making the following associations in my models: > > > doc belongsTo comment > > doc hasOne comment > > > comment belongsTo doc > > comment hasOne doc > > > ...but this gives me a weird SQL error: "Not unique table/alias: > > 'Comment'". I'm kind of lost, can anyone help me? --~--~-~--~~~---~--~~ 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: Chaining together objects
Hi i am new in cakephp but i think your problem is with cake's naming conventions. Your tables should be named "comments" and "docs" On Fri, Jun 5, 2009 at 3:28 AM, Greg Baker wrote: > > I have the following scenario.. A user can upload a document, that > document can be commented on, then a new document can be uploaded and > 'attached' to that comment. This gives a chain of objects kind of > like this: > > doc-comment-doc-comment-doc-comment > > Where the cardinality of associations is 0..1 for each association. > In my tables I have the fields doc (comment_id) and a field in comment > (doc_id). > I have tried making the following associations in my models: > > doc belongsTo comment > doc hasOne comment > > comment belongsTo doc > comment hasOne doc > > ...but this gives me a weird SQL error: "Not unique table/alias: > 'Comment'". I'm kind of lost, can anyone help me? > > > --~--~-~--~~~---~--~~ 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: Chaining together objects
Thanks, actually each object can only 'have' one other object. A doc can only have one single comment. But I will take your advice. On Jun 5, 6:09 am, John Andersen wrote: > You should probably use dynamic binding instead af static binding in > the model! > > The only static bindings I see that you can define are: > doc hasMany comments - I assume that one document can have more than > one comment! > > Then for the other, use dynamic binding. > > Enjoy, > John > > On Jun 5, 3:28 am, Greg Baker wrote: > > > I have the following scenario.. A user can upload a document, that > > document can be commented on, then a new document can be uploaded and > > 'attached' to that comment. This gives a chain of objects kind of > > like this: > > > doc-comment-doc-comment-doc-comment > > > Where the cardinality of associations is 0..1 for each association. > > In my tables I have the fields doc (comment_id) and a field in comment > > (doc_id). > > I have tried making the following associations in my models: > > > doc belongsTo comment > > doc hasOne comment > > > comment belongsTo doc > > comment hasOne doc > > > ...but this gives me a weird SQL error: "Not unique table/alias: > > 'Comment'". I'm kind of lost, can anyone help me? --~--~-~--~~~---~--~~ 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: Chaining together objects
You should probably use dynamic binding instead af static binding in the model! The only static bindings I see that you can define are: doc hasMany comments - I assume that one document can have more than one comment! Then for the other, use dynamic binding. Enjoy, John On Jun 5, 3:28 am, Greg Baker wrote: > I have the following scenario.. A user can upload a document, that > document can be commented on, then a new document can be uploaded and > 'attached' to that comment. This gives a chain of objects kind of > like this: > > doc-comment-doc-comment-doc-comment > > Where the cardinality of associations is 0..1 for each association. > In my tables I have the fields doc (comment_id) and a field in comment > (doc_id). > I have tried making the following associations in my models: > > doc belongsTo comment > doc hasOne comment > > comment belongsTo doc > comment hasOne doc > > ...but this gives me a weird SQL error: "Not unique table/alias: > 'Comment'". I'm kind of lost, can anyone help me? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Chaining together objects
I have the following scenario.. A user can upload a document, that document can be commented on, then a new document can be uploaded and 'attached' to that comment. This gives a chain of objects kind of like this: doc-comment-doc-comment-doc-comment Where the cardinality of associations is 0..1 for each association. In my tables I have the fields doc (comment_id) and a field in comment (doc_id). I have tried making the following associations in my models: doc belongsTo comment doc hasOne comment comment belongsTo doc comment hasOne doc ...but this gives me a weird SQL error: "Not unique table/alias: 'Comment'". I'm kind of lost, can anyone help me? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---