php - Follow system in CakePHP -


Actually I want to follow a system like one and the other in Twitter in KPPHP.

I have a user table in which all the user information is on each user's profile, a compliance button that is clicked once, in the "lower" table on the name of "user" Must create record, with user id and a follower_id. So every time a user clicks on a profile, he should make a new record in "this type".

I saw some questions like this but did not find a true and useful answer.

"post-text" itemprop = "text">

Something like this:

Strong> User Model

  is public $ and billions_omany = array ('follower' = & gt; array ('classname' = & gt; 'user', 'jointable' = & gt; 'your_join_table', 'foreign Key '= & gt;' following_id ',' association forwarding '= & gt;' indexed_ID ',' unique '= & gt; keep' acexisting '// if you do not want to delete the record),' follower '= & Gt; array ('classname' = & gt; 'user', 'joitable' = & gt; 'your_join_table', 'foreign That '= & gt;' Indexed_ID ',' AssociationOrgankey '= & gt;' the following_ID ',' Unique '= & gt;' // if you do not want to delete the records))  

$ Data = array ('user' = & gt; array ('id' => 2,), 'follower' => array ('follower' = & gt; array (0 = & gt; 10, 1 = & gt; 12 // If you want you can store 2 records at the same time, // that means you have a checkbox for each user and the follower can check multiple checkboxes before submitting))) < / Pre>

and then

  $ this-> User- & gt; Save all ($ data)  

Comments