CI框架随记2
2016-04-10 11:12
162 查看
1,<input type="radio" name="type" value="0" <?php echo set_radio('type','0',TRUE)?> />普通
<input type="radio" name="type" value="0" <?php echo set_radio('type','0',TRUE)?>/>情感
2,<select name="cid" id="">
<option value="1" <?php echo set_select('cid','1',TRUE)?>>情感</option> 注意:TRUE意思是默认选中的;1是值
<option value="0" <?php echo set_select('cid','2')?>>生活</option>
</select>
3,<a href=" <?php echo site_url('admin/admin/index')?>">
4,操作数据库模型
//添加动作
public function add(){
$this->load->library("form_validation");
$status = $this->form_validation->run('cate');
if($status){
//操作模型;
$this -> load -> model( "category_model" ); model( "category_model","cate");给模型起个别名
$data = array(
' cname' => $_POST['cname'],
);
$this -> category_model -> add($data); //执行到模型中的添加方法
}else{
$this->load->helper("form");
$this -> load->view(" admin/add_cate.html");
}
//注意:模型model是建在application/models/的这个目录下面;
<?php
//栏目管理模型 配置数据库是在 application/config/database.php去配置下 此处时model层
class Category_model extends CI_Model {
//添加
public function add ($data){
//使用AR模型
$this -> db -> insert('category',$data);
}
}
?>
}
/**
* 开启AR模型 一般文章管理系统会使用到AR模型
*/
$active_record = TRUE; //可以直接在控制器中$this -> db -> insert();
5,报错出现bool的返回方式 输入类的使用 这样使用更加安全
$this -> input -> post("abc"); 以post的方式接收
$this -> input -> get("abc"); 以get的方式接收
¥this -> input -> server("name");
6,全局函数是在system/core/common.php中编辑定义
7,common.php中的函数定义
//定义成功的提示函数
function success($url , $msg){
heard('Content-type:text/html;charset=utf-8');
$url = site_url($url);
echo "<script type='text/javascript'>alert('$msg');location.hrerf='$url'</script>";
die;
}
function error($msg){
heard('Content-type:text/html;charset=utf-8');
echo "<script type='text/javascript'>window.history.back();</script>";
}
8,调试模式
$this -> output -> enable_profiler(TRUE);
<input type="radio" name="type" value="0" <?php echo set_radio('type','0',TRUE)?>/>情感
2,<select name="cid" id="">
<option value="1" <?php echo set_select('cid','1',TRUE)?>>情感</option> 注意:TRUE意思是默认选中的;1是值
<option value="0" <?php echo set_select('cid','2')?>>生活</option>
</select>
3,<a href=" <?php echo site_url('admin/admin/index')?>">
4,操作数据库模型
//添加动作
public function add(){
$this->load->library("form_validation");
$status = $this->form_validation->run('cate');
if($status){
//操作模型;
$this -> load -> model( "category_model" ); model( "category_model","cate");给模型起个别名
$data = array(
' cname' => $_POST['cname'],
);
$this -> category_model -> add($data); //执行到模型中的添加方法
}else{
$this->load->helper("form");
$this -> load->view(" admin/add_cate.html");
}
//注意:模型model是建在application/models/的这个目录下面;
<?php
//栏目管理模型 配置数据库是在 application/config/database.php去配置下 此处时model层
class Category_model extends CI_Model {
//添加
public function add ($data){
//使用AR模型
$this -> db -> insert('category',$data);
}
}
?>
}
/**
* 开启AR模型 一般文章管理系统会使用到AR模型
*/
$active_record = TRUE; //可以直接在控制器中$this -> db -> insert();
5,报错出现bool的返回方式 输入类的使用 这样使用更加安全
$this -> input -> post("abc"); 以post的方式接收
$this -> input -> get("abc"); 以get的方式接收
¥this -> input -> server("name");
6,全局函数是在system/core/common.php中编辑定义
7,common.php中的函数定义
//定义成功的提示函数
function success($url , $msg){
heard('Content-type:text/html;charset=utf-8');
$url = site_url($url);
echo "<script type='text/javascript'>alert('$msg');location.hrerf='$url'</script>";
die;
}
function error($msg){
heard('Content-type:text/html;charset=utf-8');
echo "<script type='text/javascript'>window.history.back();</script>";
}
8,调试模式
$this -> output -> enable_profiler(TRUE);
相关文章推荐
- 架构师速成6.18-初中书单资料推荐
- HDU 4619 Warm up 2 最大独立集
- C++中public,protected,private派生类继承问题和访问权限问题
- hibernate 中注解 一对多 主键中mappedBy的具体使用及其含义
- BC之Claris and XOR
- IntelliJ IDEA 14控制台中文乱码的解决方法
- Digit fifth powers
- Brackets安装angularjs插件
- Brackets安装angularjs插件
- Uva12663
- 83. Remove Duplicates from Sorted List
- Spark函数详解系列--RDD基本转换
- leetcode 59. Spiral Matrix II
- Brackets安装angularjs插件
- 创建交互式shell脚本对话框
- Centos6下DRBD的安装配置
- CentOS6 下rsync服务器配置
- Installation error: INSTALL_FAILED_CONFLICTING_PROVIDER 解决方案
- 使用函数提取部分字符
- ASA与PIX防火墙的区别