标签:sdn 方法 config SM view ase led extends file
直接进入主题:
MVC:
class Nb_model extends CI_Model {
public function __construct()
{
//连接数据库
$this->load->database();
}
public function get(){
//查询数据库
$query=$this->db->get(‘users‘);
//以数组形式返回查询结果
return $query->result_array();
}
}
//防止非法訪问
if ( ! defined(‘BASEPATH‘)) exit(‘No direct script access allowed‘);
class Nb extends CI_Controller {
public function __construct()
{
parent::__construct();
//载入数据模型
$this->load->model(‘nb_model‘);
}
public function index()
{
//依据数据模型获取数据
$data[‘nb‘]=$this->nb_model->get();
//载入视图文件
$this->load->view(‘nb‘,$data);
}
}
//文件末尾凝视
/* End of file nb.php */
/* Location: ./application/controllers/nb.php */<html>
<head>
<title>CI heiilo world</title>
</head>
<body>
<!--循环输出数据-->
<?php foreach($nb as $v):?>
<h1><?=$v[‘email‘]?></h1>
<?php endforeach?>
</body>
</html>
标签:sdn 方法 config SM view ase led extends file
原文地址:https://www.cnblogs.com/zhchoutai/p/8849090.html