0
我創建笨控制器類如下笨控制器類
class Poems extends CI_Controller{
function __construct() {
parent::__construct();
$this->load->model('poem');
}
然後創建方法詩上面的類內如下
function poem($poemID){
$data['poem']= $this->poem->get_poem($poemID);
$this->load->view('poem',$data);
}
/* ** * ** * ** * ** * ** * ***/ 用於上述控制器I類模型中的get_poem()創建的方法如下
function get_poem(){
$this->db->select()->from('poems')->where(array('active'=>1,'poemID'=>$poemID))->order_by('date_added', 'desc');
$query= $this->db->get();
return $query->first_row('array');
}
當運行詩在瀏覽器中它工作正常... 當我想要在瀏覽器中將詩歌方法加載爲poems/poem時,會出現以下錯誤。
error 1: Missing argument 1 for Poems::poem()
error 2: Undefined variable: poemID
如何你get_poem()
在模型中缺失的參數修正這個錯誤
我將模型部分的參數添加到get_poem($ poemID)仍然錯誤不是固定的 – user3346201
您是否得到完全相同的錯誤? @ user3346201 – Albzi
是的,有兩個錯誤:對於詩歌:: poem()和未定義的變量:poemID都缺少參數1在控制器/ poems.php中... – user3346201