当前位置:Gxlcms > PHP教程 > thinkphp自定义业务逻辑有有关问题

thinkphp自定义业务逻辑有有关问题

时间:2021-07-01 10:21:17 帮助过:7人阅读

thinkphp自定义业务逻辑有问题?
模型:
PHP code

class DepartmentModel extends Model{
    
    public function getIndexDepart()
    {
        return 1; 
    }
      


控制器
PHP code
 
class IndexAction extends Action
{
public function index()
{
$a = D('Department');
echo "
"; 
print_r($a->getIndexDepart());
echo "
";
//echo THINK_PATH;
}

}


可是TP提示:

Model:getIndexDepart您所请求的方法不存在!


求解


------解决方案--------------------
PHP code

class IndexAction extends Action
{
    public function index()
    {
        $a = D('Department');
[color=#FF0000]        get_class($a);[/color]
        echo "
";
        print_r($a->getIndexDepart());
        echo "
"; //echo THINK_PATH; } }

人气教程排行