zoukankan      html  css  js  c++  java
  • cakePHP模型内置回调函数afterFind()的使用。

    在用find获取数据后,我们要对所获取到的数据做一些处理,这时,直接在模型层覆盖cakephp内置的回调函数,使用find时会自动调用。

    其中$baomings 就是find 到的 $this->data

    public function afterFind($baomings)
        {
            foreach ($baomings as $key => $val) {
                $baomings[$key]['Baoming']['status_cn'] = "未知";
                if ($val['Baoming']['invalid'] == 1) {
                    $baomings[$key]['Baoming']['status_cn'] = "无效";
                } else {
                    if ($val['Baoming']['status_trace'] == 0)
                        $baomings[$key]['Baoming']['status_cn'] = "未开始";
                    else if ($val['Baoming']['status_trace'] >= 1 && $val['Baoming']['status_trace'] < 6) {
                        $baomings[$key]['Baoming']['status_cn'] = "正在跟踪";
                    } else if ($val['Baoming']['status_trace'] == 6) {
                        $baomings[$key]['Baoming']['status_cn'] = "已经签约";
                    } else if ($val['Baoming']['status_trace'] == 7 || $val['Baoming']['status'] == 3) {
                        $baomings[$key]['Baoming']['status_cn'] = "已竣工";
                    }
                }
            }
            return  $baomings;
            
        }
  • 相关阅读:
    P2324 [SCOI2005]骑士精神
    Codeforces Round #574 (Div. 2) A~E Solution
    P4132 [BJOI2012]算不出的等式
    spring笔记(三)
    spring笔记(二)
    C3P0连接池参数解释
    spring笔记(一)
    hibernate笔记(四)
    hibernate笔记(三)
    hibernate笔记(二)
  • 原文地址:https://www.cnblogs.com/polax/p/4707219.html
Copyright © 2011-2022 走看看