【发布时间】:2013-11-28 14:10:43
【问题描述】:
从控制器调用模型时出现错误。 错误:- SCREAM:忽略错误抑制 (!)致命错误:在第 30 行的 C:\wamp\www\redirect\system\core\Loader.php 中找不到类“Redirection_model” 我的控制器redirection.php
<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class redirection extends CI_Controller {
function __construct()
{
parent::__construct();
//$this->layout->setLayout('layouts/main');
}
public function redirection_url()
{
if($_GET){
$get_array = $_GET;
$targetId = $get_array['tagid'];
$this->load->model('redirection_model', 'redirection');
$dynamicurl = $this->redirection->getDynamicUrl($targetId);
if($dynamicurl){
$url=$dynamicurl['url'];
redirect($url,'refresh');
}
else{
echo "Invalid Request";
}
}
else{
echo "please pass the tagid";
// $this->layout->view('redirection/redirection_url');
}
}
}
redirection_model.php
<?
class redirection_model extends CI_Model {
function __construct()
{
parent::__construct();
}
function getDynamicUrl($targetId){
$dynamicUrl= array();
$query = $this->db->get_where('dynamic_url', array('tagid' => $targetId))->row();
if($query){
$dynamicUrl['url'] = $query->url;
$dynamicUrl['userid'] = $query->userid;
return $dynamicUrl;
}
else{
return false;
}
}
}
?>
【问题讨论】:
-
而扩展类名必须以大写字母开头。
-
我试过你的解决方案先生,但力能修复错误
-
然后更新你的代码,也只是好奇:你的模型文件在模型目录中。是的?不在其他文件夹中?
-
我的模型文件只在模型目录中。
标签: php codeigniter