I am learning CakePHP. There, I am stuck with following problem:
I have a table called comments with fields comment_id, comment_title, comment_text, comment_date & user_id. Also I have my users table with fields user_id, user_name, user_email, created_date.
Then in my User model I am trying to create a hasMany relationship like :
var $hasMany = array(
'Comment' => array(
'className' => 'Comment',
'foreignKey' => 'user_id'
), );
But this giving me an error
1054 Unknown column 'User.id' in 'field list'
I know this is because I don't have an id column in my users table instead I have user_id
Now, my question is : is there a way to fix this without renaming the user_id field of user table? As this will require change in every existing code where I have used user_id ?