I know I didn't post all or even much code so you probably misunderstood me. With my blog table I do have an `id` and a `user_id` column it's just that instead of using auto_increment for the `id` column I set it the same as the users `id` with
$this->request->data['Blog']['id'] = $this->Session->read('Auth.User.id');
when a new blog is created... I know it's probably wrong to do so, but it is easier for me to keep track of things, and then when I'm verifying if someone should be editing a blog or whatever I just have to compare the Blog.id to their session id... I'm a newb so I don't understand how to do it any other way especially when you start distancing yourself from the root association (for example user owns a blog but the blog posts belong to the blog) I guess in that instance I really should just add a user_id column to the blog posts. I just wasn't that smart when I started this.
Anyways, besides that neither solution worked and really the query selection should have worked... so I think I'm just going to add a user_id field to the posts and verify ownership the same way I have been with blogs, profiles, and everything else users own.
Sorry if I've wasted your time with newbie issues :-P
Anyways, besides that neither solution worked and really the query selection should have worked... so I think I'm just going to add a user_id field to the posts and verify ownership the same way I have been with blogs, profiles, and everything else users own.
Sorry if I've wasted your time with newbie issues :-P
On Friday, June 1, 2012 4:56:42 PM UTC-5, stork wrote:
By the way, read whole chapter about model associations http://book.cakephp.org/2.0/en/models/associations-linking-models-together.html and follow cake conventions for primary/foreign keys - that means NOT User.id == Blog.id BUT User.id == Blog.user_id.--
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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
No comments:
Post a Comment