CodeIgniter 使用开发笔记 - 2 - xiaobin

一个简略的比如 我们通过一个比如来说明运用CI是多么简略的作业! 我们首要下载一个IBM开发者网站上的一个比如来做移植。 下载地址:http://www.ibm.com/developerworks/web/library/wa-codeigniter/   我们初步吧! 基类   在运用老版另外CI的时分,我们要改动一下基类的称谓。    序号 老版别(V1.6.2) 新版别(V2.1.3) 备 http://www.kp1111.info 注 1 Controller CI_Controller   2 Model CI_Model         在新版别中现已更改了默许的布局器。 比如,老版别中在每个继承类的榜首段都有:          function 类名(){               parent::Model();        }    或 function 类名(){               parent::Controller();        }         新版别都由两个下划线和construct为布局器名 function __construct(){               parent::__construct();        }                   XSS过滤器 在config目录下的config.php中: $config['global_xss_filtering'] = FALSE; 更改为 $config['global_xss_filtering'] = TRUE;     函数更改: 把“input”改动为“security” 由 $this->input->xss_clean 成为 $this->security->xss_clean                                                         我们的“仓库”   首要,填写位于config文件夹的database.php中的用户名、暗码、数据库名等   $db['default']['username']= 'root'; $db['default']['password']= 'qazxsw'; $db['default']['database']= 'carnumber';   然后,创建数据表   CREATE TABLEcontacts (   id int NOT NULL AUTO_INCREMENT,   name varchar(128) NOT NULL,   email varchar(255) NOT NULL,   notes text NOT NULL,   stamp timestamp NOT NULL defaultCURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,   ipaddress varchar(32) NOT NULL,   PRIMARY KEY (id))AUTO_INCREMENT=100001;   结尾,我们在model中编写代码即可:   functionaddContact(){       $now= date("Y-m-d H:i:s");        $data = array(               'name' =>$this->security->xss_clean($this->input->post('name')),               'email' =>$this->security->xss_clean($this->input->post('email')),               'notes' =>$this->security->xss_clean($this->input->post('notes')),               'ipaddress' =>$this->input->ip_address(),               'stamp' => $now               );          $this->db->insert('contacts',$data);  }    完结的效果,如下图:   http://www.gookp11.com 
posted @ 2013-04-08 02:37  chinadiy197601  阅读(202)  评论(0编辑  收藏  举报