错误:在数据源默认值中找不到模型SocialProfile的表social_profiles

时间:2015-02-18 07:29:07

标签: facebook cakephp model hybridauth social-media

我正在尝试使用hybridauth

让社交登录工作

我的app / Model / SocialProfile.php看起来像

<?php
App::uses('AppModel', 'Model');
App::uses('AuthComponent', 'Controller/Component');

class SocialProfile extends AppModel {
        public $belongsTo = 'User';
}

我的app / Model / User.php看起来像

<?php
App::uses('AppModel', 'Model');

class User extends AppModel {
    public $hasMany = array(
        'SocialProfile' => array(
            'className' => 'SocialProfile',
        )
    );
....

我收到此错误: 错误:在数据源默认值中找不到模型SocialProfile的表social_profiles。

谢谢你的帮助

1 个答案:

答案 0 :(得分:0)

  

如果您的数据库中存在social_profiles表,则不需要   在模型中定义。但在你的情况下它不起作用。所以你需要    CakePHP 中的替代流程。

App::uses('AppModel', 'Model');
App::uses('AuthComponent', 'Controller/Component');

class SocialProfile  extends AppModel {
    public $useTable = 'social_profile '; 
    // This model uses a database      table 'social_profile'
    public $name = 'SocialProfile ';  
   // If you do not specify it in your model file it will be set to the 
   // class name by constructor.
}

我希望上面的模型能够完美地为您服务。我找到了您的解决方案,请阅读此Docs

相关问题