search
Homephp教程PHP开发CI Framework Notes 2

CI Framework Notes 2

Dec 29, 2016 am 09:38 AM
ci framework

1,

<input type="radio" name="type" value="0" <?php echo set_radio(&#39;type&#39;,&#39;0&#39;,TRUE)?> />普通
<input type="radio" name="type" value="0" <?php echo set_radio(&#39;type&#39;,&#39;0&#39;,TRUE)?>/>情感

2,

<select name="cid" id="">
<option value="1" <?php echo set_select(&#39;cid&#39;,&#39;1&#39;,TRUE)?>>情感</option> 注意:TRUE意思是默认选中的;1是值
<option value="0" <?php echo set_select(&#39;cid&#39;,&#39;2&#39;)?>>生活</option>
</select>

3,

<a href=" <?php echo site_url(&#39;admin/admin/index&#39;)?>">

4, Operation database model

//添加动作
public function add(){
$this->load->library("form_validation");
$status = $this->form_validation->run(&#39;cate&#39;);
if($status){
//操作模型;
$this -> load -> model( "category_model" ); model( "category_model","cate");给模型起个别名
$data = array(
&#39; cname&#39; => $_POST[&#39;cname&#39;],
);
$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(&#39;category&#39;,$data);
}
}
?>
}
/**
* 开启AR模型 一般文章管理系统会使用到AR模型
*/
$active_record = TRUE; //可以直接在控制器中$this -> db -> insert();

5, When an error occurs, the return method of bool input class is safer to use.

$this -> input -> post("abc"); 以post的方式接收
$this -> input -> get("abc"); 以get的方式接收
¥this -> input -> server("name");

6. The global function is edited and defined in system/core/common.php

7 , Function definition in common.php

//定义成功的提示函数
function success($url , $msg){
heard(&#39;Content-type:text/html;charset=utf-8&#39;);
$url = site_url($url);
echo "<script type=&#39;text/javascript&#39;>alert(&#39;$msg&#39;);location.hrerf=&#39;$url&#39;</script>";
die; 
}
function error($msg){
heard(&#39;Content-type:text/html;charset=utf-8&#39;);
echo "<script type=&#39;text/javascript&#39;>window.history.back();</script>";
}

8, Debug mode

$this -> output -> enable_profiler(TRUE);

The above is the content of CI Framework Note 2, more related Please pay attention to the PHP Chinese website (www.php.cn) for content!


Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools