首先在content控制器文件夹下,新建一个文件my_index.php
<?php
class MY_index extends index{
function __construct() {
parent::__construct();
$this->db = pc_base::load_model('content_model');
}
public function test() {
$test="test";
$sql="select titlefrom v9_news";
$test=$this->db->query($sql);
$Result = $this->db->fetch_array();
var_dump($Result);
include template('content','test',$default_style);
}
}
?>
//模板文件test.html输出代码
{loop $Result $key $v}
{$v[title]}<br>
{/loop}
代码如下,可以直接操利用query操作数据库,页面访问地址 /index.php?m=content&c=index&a=test