|
这是我写的代码
hello.php:
<?php
class Hello extends Controller{
function Hello(){
parent::Controller();
$this->load->database();
}
function index(){
echo "hello word ";
}
function show(){
$this->load->model('show_model');
$data['query']=$this->show_model->show_page();
$this->load->view('show',$data);
}
}
?>
show_model.php 代码:
<?php
class Show_model extends Model{
function Show_model(){
parent::Model();
}
function show_page(){
$query=$this->db->get('phpcms_content');
return $query->result();
}
}
?>
视图文件 show.php代码:
<?php
foreach($data->result() as $row)
{
?>
<p><?php echo $row->title ; ?></p>
<?php
}
?>
数据库配置信息:
$active_group = "default";
$active_record = TRUE;
$db['default']['hostname'] = "localhost";
$db['default']['username'] = "root";
$db['default']['password'] = "wonder";
$db['default']['database'] = "phpcms";
$db['default']['dbdriver'] = "mysql";
$db['default']['dbprefix'] = "";
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = "";
$db['default']['char_set'] = "utf8";
$db['default']['dbcollat'] = "utf8_general_ci";
访问时 :http://localhost/index.php/hello/show/ 时 出现错误
哪位大哥 能帮我看看 或者 告诉我哪里出错了啊 本人刚刚接触 condeigniter |
|