CI Model
来源:互联网 发布:怎样用c语言播放音乐 编辑:程序博客网 时间:2024/05/28 15:11
文件名需要小写,类名需要第一个字母大写 方法就是控制器所需要的数据
class User_model extends CI_Model{
//获得所有用户
public function getAll(){
$res=$this->db->get('user');
return $res->result();
}
//在Model方法,返回给控制器
public function info(){
return '用户列表';
}
}
//控制器获得Mode中的数据
class User extends CI_Controller{
public function index(){
//加载用户模型,并且起一个别名
$this->load->model('User_model','user');
//获得模型对象调用模型中的方法
$list=$this->user->getAll();
$info=$this->user->info();
//将从模型中获得的方法通过控制器传递给视图
$this->load->view('user/index',array('list'=>$list,'info'=>$info));
}
}
//视图负责按照要求显示数据
<!DOCTYPE html>
<html>
<head>
<title>index.php/user/index</title>
</head>
<body align='center'>
<h3>显示:<?php echo $info;?></h3>
<table border="1" align='center'>
<tr><th>编号</th> <th>用户名</th> <th>密码</th> </tr>
<?php foreach($list as $items):?>
<tr>
<th><?=$items->id?></th>
<th><?=$items->username?></th>
<th><?=$items->password?></th>
</tr>
<?php endforeach;?>
</table>
</body>
</html>
//CI数据输入
$this->input->get('id');
$this->input->post('id');
$this->input->server('id');
$this->input->cookie('id');
- CI Model
- CI(3) model CRUD
- CI框架中封装Model
- 【CI 框架】CI框架两个application共用同一套model
- CI框架源码阅读---------Model.php
- CI框架源码阅读---------Model.php
- CI项目架构(2)---共用model、library、helper
- CI框架下 创建自己的model层
- ci
- ci
- CI
- ci
- CI 3.0.0 Unable to locate the model you have specified:*_model
- CI框架源码完全分析之核心文件(模型)Model.php
- CI框架源码解析十五之模型类文件Model.php
- CI框架的全局函数、类库中调用model层的方法
- Model?
- Model
- linux学习笔记(9)
- Chilkat.NET.Components.for.NET.4.0.
- 4.S5PV210中断相关寄存器详解
- 网页JS蜂巢特效
- 关于CSS如果绘制三角形
- CI Model
- UIEdgeInsetsMake设置UIButton的图片、文字的相对位置
- 字符串操作
- head first Thread.join()
- HTTP协议和2种请求的方法
- 椭圆检测之边缘点合并
- Mac上传(下载)文件到CentOS服务器
- 在Oracle中create schema,怎么把从另一台服务器中的dat文件exp出去,然后imp进新建的schema.
- 【Unity】类似鼠标按住时只返回一次True的条件判断