Iluvatar+ Posted February 28, 2012 Share Posted February 28, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/257927-belongsto-relations/ Share on other sites More sharing options...
batwimp Posted February 28, 2012 Share Posted February 28, 2012 You would probably get better response if you posted this in the Application Frameworks section of the site. They are more cake specific. Quote Link to comment https://forums.phpfreaks.com/topic/257927-belongsto-relations/#findComment-1322061 Share on other sites More sharing options...
jcombs_31 Posted February 29, 2012 Share Posted February 29, 2012 Can you please show your table descriptions. E.g., "Describe table users", "Describe table pages" FYI, you can use the bake console utility to create your basic models, controllers, views as long as your DB uses the cake conventions. Quote Link to comment https://forums.phpfreaks.com/topic/257927-belongsto-relations/#findComment-1322148 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.