Jump to content

Recommended Posts

This is a long shot like seen as no one seems to respond to any cakephp related questions/problems.

But anyway here it goes…

I need to create a simple relationship between tables (User.id => Pages.user_id). I have created relationships before in cake but only in order to find and display data in the controller or the view.  I need this specific relationship to be set in the model ‘User’, the reason why is that I want the Auth (current user) session to contain its foreign relations in order to use that related data to set permissions within the User controller.

This is my model ATM

class User extends AppModel {
var $name = 'User';
var $belongsTo = array(Page => array('className'     => Page,
            											 					          		  'foreignKey'    => user_id,
        )
    );

 

From how I have read the syntax is fine, it’s just seems as though cake automatically assumes that the foreign key is within the user model rather than the pages  model.

 

Link to comment
https://forums.phpfreaks.com/topic/257927-belongsto-relations/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.