zl程序教程

您现在的位置是:首页 >  工具

当前栏目

CI笔记

笔记 CI
2023-09-14 09:00:26 时间
 //select id,name from tableName where id =3 order by id desc limit 2,3  $res=$this- db- select(id,name)   - from(user)   - where(id =,3)   - limit(3,2)//跳过2条,取出3条数据   - order_by(id desc )   - get();  //显示最近一条SQL  echo $this- db- last_query();  //where  //$res=$this- db- where(name,mary)- get(user);  //$res=$this- db- where(name !=,mary)- get(user);  //$res=$this- db- where(array(name= mary))- get(user);  //$res=$this- db- where(array(name= mary,id = 2))- get(user);  复杂的查询,请用$this- db- query($sql,$data);//使用问号绑定参数 扩展CI控制器  application/core/MY_Controller.php  控制器就要以继承自MY_Controller  application/config/config.php  $config[subclass_prefix] = MY_;  继承自CI_Model  在模型中,可以直接使用超级对象中的属性  文件名,全小写  类名首字母大写  建议使用_model作为后缀,防和控制器类名冲突 url相关函数  $this- load- helper(url);  //可以根需要配置自动加载  //application/config/autoload.php  //$autoload[helper] = array(url);  site_url(控制器/方法)  base_url()  application/config/routes.php  //默认控制器  $route[default_controller] = "welcome"; http://localhost/ci/index.php/news/201309/4.html  $route[news/[\d]{6}/([\d]+)\.html]=article/show/$1; 隐藏入口文件  开始apache的rewrite模块,在httpd.conf文件中  LoadModule rewrite_module modules/mod_rewrite.so  重启apache  在入口文件同级目录中,放入一个.htaccess文件  内容如下:   IfModule mod_rewrite.c      RewriteEngine on      RewriteCond %{REQUEST_FILENAME} !-d      RewriteCond %{REQUEST_FILENAME} !-f      RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]   /IfModule  //装载类文件  $this- load- library(pagination);  $this- load- helper(url);  //每页显示10条数据  $page_size=10;  $config[base_url] =site_url(user/test);  //一共有多少条数据  $config[total_rows] = 100;  //每页显示条数  $config[per_page] = $page_size;  $config[first_link] = 首页;  $config[next_link] = 下一页;  $config[uri_segment]=3;//分页的数据查询偏移量在哪一段上  $this- pagination- initialize($config);  $offset=intval($this- uri- segment(3));//与$config[uri_segment]对应  $sql="select * from blog_user limit $offset, $page_size";  echo $sql;  $data[links]=$this- pagination- create_links();  $this- load- view(user/test,$data);  1.手动创建好上传目录
 form action=" ?php echo site_url(user/upload)? " method="post" enctype="multipart/form-data" 

 input type="file" name="pic" / 

 input type="submit" value="上传" 

 /form 
 
//上传目录需要手工创建  $config[upload_path]=./uploads/;  //允许  $config[allowed_types]=gif|png|jpg|jpeg;  $config[max_size] = 10000;  //生成新文件名  $config[file_name]=uniqid();  //装载文件上传类  $this- load- library(upload,$config);  $this- upload- do_upload(pic);  var_dump($this- upload- data());  //获取上传之后的数据  $data=$this- upload- data();  echo $data[file_name];  //生成一个随机不重复的字符串作为加密用的key   //保存到application/config/config.php   //$config[encryption_key] = adb8bf6d0ac4e17b42a80941582497a4;   //echo md5(uniqid());exit;   $this- load- library(session);   $user=array(id= 3,name= jack);   //session_start();   //$_SESSION[user]=$user;   $this- session- set_userdata(user,$user);   //不在这这里获取刚放入的数据   //只有页在从新加载或跳转到别的url中,才能获取到   //一次性的数据,只能读取一次   $this- session- set_flashdata(test,aaaaaaaaaaaaaa);  public function show_session(){   $this- load- library(session);   //取CI session中的数据   $user=$this- session- userdata(user);   var_dump($user);   //下次刷新,就没有了   $test=$this- session- flashdata(test);   echo $test;  $this- load- library(form_validation);  $this- form_validation- set_rules(name, 用户名, required);  $this- form_validation- set_rules(email, 邮箱, valid_email);  $bool=$this- form_validation- run();  if($bool){   //调用模型保存到数据库  }else{   //显示错误信息   $this- load- view(user/add);  }
 ?php echo validation_errors();? 

 form action=" ?php echo site_url(user/insert);? " method="post" 

 name input type="text" name="name" value=" ?php echo set_value(name)? " / 

 ?php echo form_error(name, span , /span )? 

 password input type="password" name="password" / br 

 email input type="text" name="email" value=" ?php echo set_value(email)? " / 

 ?php echo form_error(email)? 

 input type="submit" value="submit" / 

 /form 



Travis CI简介 什么是持续集成? Travis CI 提供的是持续集成服务(Continuous Integration,简称 CI)。它绑定 Github 上面的项目,只要有新的代码,就会自动抓取。然后,提供一个运行环境,执行测试,完成构建,还能部署到服务器。
CI/CD持续集成概念(一) 持续集成 1.集成的概念 1.1.什么是集成 在实际的软件开发中,常常会有如下两种场景: 1.现在有一个电商平台开发,由于平台需要开发的某块较多,此时需要不同的开发人员开发不同的模块,最后将所有人开发好的代码集成到一个系统中,集成完毕后需要对其进行部署上线 2.随着时间的推移,该系统无论是bug修复、还是新功能开发,后续都需要对系统进行不断的更新迭代
互联网软件的开发和发布,已经形成了一套标准流程,最重要的组成部分就是持续集成(Continuous integration,简称CI)。
GitLab-CI就是一套配合GitLab使用的持续集成系统(当然,还有其它的持续集成系统,同样可以配合GitLab使用,比如Jenkins)。