Sorry for the non-descript title, but I\'m not sure how to phrase it. Currently, I am trying my hand at developing a Twitter clone with cakePHP, since I\'m new to web progr
app/models/user.php
class User extends AppModel{
var $name = 'User';
var $hasAndBelongsToMany = array(
'Follower' => array(
'className' => 'Follower',
'joinTable' => 'user_users',
'foreignKey' => 'user_id',
'associationForeignKey' => 'child_user_id'
)
)
}
app/models/follower.php
class Follower extends AppModel{
var $name = 'Follower';
var $useTable = 'users';
}
You will have to make a table user_users with the fields user_id and child_user_id. child_user_id would be the follower ID, you could name it follower id if you want but it might be confusing if you need to make a similar relation in the future.
Try it out.