dqyl2374 2014-06-14 12:49
浏览 38

在数据库YII中找不到活动记录类“Users”的表“users”

enter image description herei have tried to call a function (getMenu()) in CommonFunction.php (location : components/CommonFunction.php) , which will return some user data, but when i transferred my application from godaddy (shared hosting) to resellerclub (shared hosting) , following error showing.

The table "users" for active record class "Users" cannot be found in the database

  1. table exists in database
  2. letter case for file and class name for model checked
  3. using the correct db connection
  4. created a function (say abc()) in CommonFunctions.php which is successfully fetching user information.
  5. when tried to call above mentioned abc() from getMenu() , it again showing above error
  6. am able to call the getMenu function from my other controllers but there is not issue for that
  7. But when i tried to call getMenu from this specific function it is showing error
  8. If assigned a static value to first fetching, it will show error for the next fetching in the same function .

commonFunction.php

   public static function GetMenu($user_id = 0) {

    $user_info = Users::model()->findByPk($user_id);
    if (!isset($user_info) || count($user_info) < 1)
        return;
    $user_profile = UserProfile::model()->find('user_id=:user_id', array(':user_id' => $user_id));
    $creteria = new CDbCriteria();
    $creteria->condition = "contributor=\"$user_info->user_name\"";
    $photo_upload_count = Godown::model()->count($creteria);

    $creteria = new CDbCriteria();
    $creteria->condition = "user_email=\"$user_info->email\"";
    $photo_purchase_count = Downloads::model()->count($creteria);

    //echo $photo_purchase_count; exit;
    $creteria = new CDbCriteria();
    $creteria->condition = "contributor_user_name=\"$user_info->user_name\"";
    $photo_sale_count = Downloads::model()->count($creteria);
    //echo $photo_sale_count; exit;

    $base = Yii::app()->getBaseUrl(true);
    $profile_pic_org = false;
    $profile_dummy = "$base/images/profile-img.jpg";
    if (isset($user_profile->profile_pic) && $user_profile->profile_pic != '') {
        $profile_pic_url = "$base/profile-pic/thumb/" . $user_profile->profile_pic;
        $profile_pic_org = "$base/profile-pic/" . $user_profile->profile_pic;
    } else {
        $profile_pic_url = "$base/images/profile-img.jpg";
        $profile_pic_org = "$base/images/profile-img.jpg";
    }
    if (isset($user_profile) && count($user_profile) > 0) { // profile for the user is almost complete , we can fetch that info too;
        $name = $user_profile->first_name . ' ' . $user_profile->last_name;
    } else {
        $a=explode('@', $user_info->email);
        $name = reset($a);
    }
    if ($user_info->user_type == 'c') { // find the statics if and only if the user is a contributor
        $creteria = new CDbCriteria();
        $creteria->condition = "contributor=\"$user_info->user_name\" and display_status =\"\"";
        $photo_pending_approval_count = Godown::model()->count($creteria);

        $creteria = new CDbCriteria();
        $creteria->condition = "contributor=\"$user_info->user_name\" and display_status =\"N\"";
        $photo_rejected_count = Godown::model()->count($creteria);

        $creteria = new CDbCriteria();
        $creteria->condition = "contributor=\"$user_info->user_name\" and display_status =\"Y\"";
        $photo_accepted_count = Godown::model()->count($creteria);
        $folder = self::GetUploadFolder($user_id);
        $folder = $folder['orginal'];
        $penging_file_count = 0;
        //echo $folder; exit;

    }
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 keil的map文件中Image component sizes各项意思
    • ¥30 BC260Y用MQTT向阿里云发布主题消息一直错误
    • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
    • ¥15 划分vlan后,链路不通了?
    • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
    • ¥15 Vue3 大型图片数据拖动排序
    • ¥15 Centos / PETGEM
    • ¥15 划分vlan后不通了
    • ¥20 用雷电模拟器安装百达屋apk一直闪退
    • ¥15 算能科技20240506咨询(拒绝大模型回答)