0

在我的 RedpCategory 表中,我使用 cat_id 作为primaryKey,类似于下面的模型

在 RedpCategory 模型中:

<?php
   App::uses('AppModel', 'Model');
   class RedpCategory extends AppModel {
   public $useTable = 'redp_category';
   public $name = 'RedpCategory';
   public $primaryKey = 'cat_id';
//
//
}

在我看来:

public function view($id = null) {
    if (!$id) {
        throw new NotFoundException(__('Invalid redeem category'));
    }

    $redp_categories = $this->RedpCategory->findById($id);
    if (!$redp_categories) {
        throw new NotFoundException(__('Invalid redeem category'));
    }
    $this->set('redp_categories', $redp_categories);
}

单击类别名称链接时出现错误:“未定义列:7 错误:列 RedpCategory.id 不存在”

我该如何解决这个问题?

任何答案将不胜感激。谢谢您。

4

1 回答 1

4

findById()将搜索文字“id”字段。

尝试将您的 find 语句切换为:

$this->RedpCategory->findByCatId($id);

编辑:编辑不正确的信息

于 2014-09-01T09:05:42.140 回答