1,
/>普通 />情感
2,
3,
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/的这个目录下面;
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 "";
die;
}
function error($msg){
heard('Content-type:text/html;charset=utf-8');
echo "";
}8,调试模式
$this -> output -> enable_profiler(TRUE);
以上就是CI框架随记2的内容,更多相关内容请关注PHP中文网(www.php.cn)!










