Monday, June 27, 2011

Re: Display posts on the home page AND posts visible to users only

to assign multiple posts to ur users u should work with the relations
between models in ur case u must add a variable in ur users model
(user.php) which is $hasMany like this:

var $hasMany = "Post";

after that u should add a field in ur posts table in ur database which
is user_id

Hpoe it helps

On Jun 27, 8:37 am, Dwayne Hanekamp <dwaynehanek...@gmail.com> wrote:
> Create a user_id field in your posts databasetable. This way you can
> assign
> a user_id to each blogpost. Example:
>
> Usertable:
>
> id int(11)
> username varchar(255)
> password varchar(255)
> etc etc...
>
> Posttable:
> id int(11)
> user_id int(11) --> Redirecting to the usertable's id
> title varchar(255)
>
> etc...
>
> Hope this helps!
>
> On 27 jun, 07:22, Jeremie <jeere...@gmail.com> wrote:
>
>
>
>
>
>
>
> > Thanks. That works. I can now link to my notes. Cool feature.
>
> > *To assign user to post, you have to create user_id field in your post.
> > You can assign the user_id upon create new post.*
>
> > I am not sure to understand what you mean. Would you have an example to show
> > me?

--
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: