2

我无法解决这个问题,我宁愿不必用 unBinds 填充我的控制器。我有一个需要验证的贤者薪酬表格。因此,我使用以下内容建立了一个圣人模型:

class Sage extends AppModel {

    var $useTable = false;
    var $_schema = array(
        'CardHolderName'        =>array('type'=>'string', 'length'=>100), 
        'CardType'      =>array('type'=>'string', 'length'=>100), 
        'CardNumber'        =>array('type'=>'string', 'length'=>100), 
        'EndMonth'      =>array('type'=>'string', 'length'=>100), 
        'EndYear'       =>array('type'=>'string', 'length'=>100), 
        'BILLING_address_line_1'        =>array('type'=>'string', 'length'=>100), 
        'BILLING_city'      =>array('type'=>'string', 'length'=>100), 
        'BILLING_county'        =>array('type'=>'string', 'length'=>100), 
        'BILLING_country'       =>array('type'=>'string', 'length'=>100), 
        'BILLING_country'       =>array('type'=>'string', 'length'=>100), 
        'BILLING_post_code'     =>array('type'=>'string', 'length'=>100), 
        'DELIVER_name'      =>array('type'=>'string', 'length'=>100), 
        'DELIVER_address_line_1'        =>array('type'=>'string', 'length'=>100), 
        'DELIVER_city'      =>array('type'=>'string', 'length'=>100), 
        'DELIVER_county'        =>array('type'=>'string', 'length'=>100), 
        'DELIVER_country'       =>array('type'=>'string', 'length'=>100), 
        'DELIVER_post_code'     =>array('type'=>'string', 'length'=>100), 
        'CSV'       =>array('type'=>'string', 'length'=>3)

    );

    public $validate = array(
        'CardHolderName'=>array(
            'Please enter your name.'=>array(
                'rule'=>'notEmpty',
                'message'=>'Please enter your name.'
            )
        ),
        'CardType'=>array(
            'Card Type Select'=>array(
                'rule'=>'notEmpty',
                'message'=>'You must select a card type.'
            )
        ),
        'CardNumber'=>array(
            'Card Number Length'=>array(
                'rule'=> array('between', 16, 20),
                'message'=>'Card numbers are at least 16 numbers long.'
            ),
            'Not empty'=>array(
                'rule'=> 'notEmpty',
                'message'=>'Card Number is missing.'
            ),
            'Is a number' => array(
                'rule' => 'numeric',
                'message' => 'This must be a number (no spaces either).'
            )
        ),
        'EndMonth'=>array(
            'End Month Select'=>array(
                'rule'=>'notEmpty',
                'message'=>'No Month.'
            )
        ),
        'EndYear'=>array(
            'End Year Select'=>array(
                'rule'=>'notEmpty',
                'message'=>'No Year.'
            )
        ),
        'CSV'=>array(
            'Card Number Length'=>array(
                'rule'=> array('between', 3, 3),
                'message'=>'A CSV is 3 numbers long.'
            ),
            'CSV not empty'=>array(
                'rule'=>'notEmpty',
                'message'=>'Please enter your security code.'
            ),
            'Is a number' => array(
                'rule' => 'numeric',
                'message' => 'A CSV is 3 numbers long.'
            )
        )
    );
}

但是,当我转到订单的索引页面(其中有一个$this->paginate('Order');)时,我得到以下信息:

错误:SQLSTATE [42S02]:未找到基表或视图:1146 表 'wr_shop.sages' 不存在

SQL 查询: SELECT COUNT(*) AS countFROM wr_shoporders如左 Order加入wr_shopusersAS UserON ( Order. user_id= User. id) 左连接wr_shopbasketsAS BasketON ( Basket. order_id= Order. id) 左连接wr_shopsagesAS SageON ( Sage. order_id= Order. id) 其中 1 = 1

有人可以告诉我我错过了什么,我似乎无法在任何地方在线找到答案。

---UPADATE--- 我已经通过创建一个'sages'表临时解决了这个问题,即使它永远不会保存任何数据。

4

2 回答 2

0

今天我遇到了同样的问题,就我而言,问题是我的表单发送了 ID 字段。当我删除 ID 字段时,验证执行得很好。

于 2013-11-13T01:03:35.713 回答
0

您的 Sage 模型未正确加载,而是使用了 AppModel 实例。

检查路径、文件名和文件扩展名:app/Model/Sage.php

于 2012-07-28T19:57:46.873 回答