在模型中调用函数时出错

时间:2011-07-27 18:50:29

标签: php function codeigniter model

我有一个包含两个函数的模型,如下所示:

<?php

class FotoModel extends CI_Model
{
    function __construct()
    {
        parent::__construct();
    }

    function getFotosByCat($cat)
    {
        $this->load->helper("file");
        switch($cat)
        {
            case "bloemen" : return get_filenames("/images/foto/bloemen/");
            case "dieren" : return get_filenames("/images/foto/dieren/");
            case "andere" : return get_filenames("/images/foto/andere/");
        }
    }

    public function getFotoLinksByCat($cat)
    {
        $fileNames = getFotosByCat($cat);
        //i do stuff with $fileNames and provide a return statment..
    }
}

?>

我在我的控制器中加载模型并使用$ fileNames的一些静态数据测试第二个方法,一切正常。只有当我从第二个函数调用第一个函数(带有switch / case语句的函数)时(如代码示例所示),我才会收到错误。

事情是我甚至没有看到什么样的错误。这是因为测试和尝试我知道错误必须在第一个函数中。有谁可以帮我解决这个问题?

2 个答案:

答案 0 :(得分:2)

尝试:

$fileNames = $this->getFotosByCat($cat);

答案 1 :(得分:-1)

我在你的开关中注意到你没有使用过任何休息;是的

(对不起我是一个SO n00b,我不能为我的生活找出内联代码范围..)