为什么加了读取数据库的操作后 就没有反应了呢?
function index(){
$this->load->model('Report_model');
$data['report'] = $this->Report_model->gettop(5);
$this->load->view('template',$data);
}
<?php
class Report_model extends Model
{
function Report_model()
{
parent::Model();
}
function gettop($num)
{
$data = array();
$this->db->selcet('id,title,category,timestamp');
$this->db->order_by('id','desc');
$this->db->limit($num,0);
$Q = $this->db->get('mwc_article');
if($Q->num_rows()>0)
{
foreach ($Q->result_array() as $row)
{
$data[] = $row;
}
}
$Q->free_result();
return $data;
}
function getall()
{
;
}
}
?> index这个方法页面显示空白 啥都看不到~~~ config开启debug,查CI log看停在哪了 Undefined property: CI_Loader::$Report_model
这个error不应该呀 debug停止在:DEBUG - 2010-01-18 13:49:20 --> Model Class Initialized
没有发现error呀 还是不行 太粗心了 select写错~~~ 你的控制器是不是class Index extends Controller ?
如果是的话,请修改控制器名字,CI控制器不能以Index命名 结贴:是自己太粗心了 将select写错。。
在这里学到一点 就是ci的debug模式。调试代码很有用。
页:
[1]