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,来源[email protected]搞@^&代*@码网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);
以上就是CI框架随记2的内容,更多相关内容请关注搞代码!