du5114 2014-02-06 14:50
浏览 43
已采纳

CakePHP - 调用未定义的函数find()

I'm trying to call the find() function of a loaded model and I get the following error: Call to undefined function find()

If I can call create() and save(), why is find() undefined?

public function admin_upload() {
        $this->layout = 'ajax';
        $this->loadModel('TempImage');

        $uploadedFileName = $_FILES['data']['name']['Staticpage']['main_image'];
        $uploadedType = $_FILES['data']['type']['Staticpage']['main_image'];
        $uploadedTmpFileName = $_FILES['data']['tmp_name']['Staticpage']['main_image'];
        $uploadedError = $_FILES['data']['error']['Staticpage']['main_image'];
        $uploadedSize = $_FILES['data']['size']['Staticpage']['main_image'];

        $this->TempImage->create();

        $imageData = array(
            'name' => $uploadedFileName,
            'type' => $uploadedType,
            'tmp_name' => $uploadedTmpFileName,
            'error' => $uploadedError,
            'size' => $uploadedSize
        );

        $temporaryData = array(
            'path' => $imageData
        );

        $this->TempImage->save($temporaryData);

        $lastTempImageThumbPath = $this->TempImage-find(
                'first',
                array(
                    'conditions' => array(
                        'id' => $this->TempImage->getLastInsertID()
                    )
                )
        );
        $this->set('thumb', $lastTempImageThumbPath['TempImage']['thumb_path']);
    }
  • 写回答

1条回答 默认 最新

  • dongzhou1901 2014-02-06 14:52
    关注

    Just a small fault, you're missing the >

    Wrong: $this->TempImage-find(

    Right: $this->TempImage->find(

    Comment from Brian Warshaw:
    Just to add a little clarity so you understand, when that > was missing, PHP was interpreting as you trying to subtract the results of the undefined function find from the value of $this->TempImage

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置