【问题标题】:Error: Table social_profiles for model SocialProfile was not found in datasource default错误:在数据源默认值中找不到模型 SocialProfile 的表 social_profiles
【发布时间】:2015-04-19 03:16:26
【问题描述】:

我正在尝试使用 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。

感谢您的帮助

【问题讨论】:

  • 你的表名是否与 -> social_profiles 完全一样?

标签: facebook cakephp model hybridauth social-media


【解决方案1】:

如果您的数据库中存在 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

找到了您的解决方案

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-05-12
  • 1970-01-01
  • 2015-11-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多