Twig和Medoo之 与CI框架有个约会

CI框架


  • 介绍

    优雅的CodeIgniter,称之为CI框架,CodeIgniter 是一个小巧但功能强大的 PHP 框架,作为一个简单而“优雅”的工具包,它可以为开发者们建立功能完善的 Web 应用程序。

  • 安装

    https://codeload.github.com/bcit-ci/CodeIgniter/zip/3.0.2  
    

    下载解压即可使用

  • 文档

      http://codeigniter.org.cn/user_guide/general/controllers.html#hello-world
    
  • 配合Medoo 和 Twig 飞起来

  • 查 多条
      $students = $this->db->select("ci_student", "*");
          
      echo $this->twig->render(
          'index.html',
          array(
              'page_title' => '主页',
              'students' => $students
          )
      );
    

    传递参数到index.html

    index.html 这个来解析

    {% for item in students %}

    {% endfor %}

    用过django的同学可以非常舒服的过渡到twig模板引擎,因为写法几乎是一样。

  • 查一条
      $student = $this->db->get('ci_student', "*", ["id"=>$id]);
    
      echo $this->twig->render(
              'edit.html',
              array(
                  'student' => $student,
              )
      );
    
  •   $id = $this->input->post('id');
      $name = $this->input->post('name');
      $age = $this->input->post('age');
    
      $this->db->update("ci_student",
      [
          "name" => $name,
          "age"  => $age
      ],
      [
          "id" => $id
      ]);
    

$this->input->post('id')

这样写就是获取post方式的数据

  •   public function del($id)
      {
          $this->db->delete("ci_student",
          [
          "id" => $id
          ]);
      }
    

    这样的写法,就是获取get方式的数据

  •   $name   = $this->input->post('name');
      $age    = $this->input->post('age');
    
      $this->db->insert("ci_student",
      [
          "name" => $name,
          "age"  => $age
      ]);
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 135,001评论 19 139
  • 1. Java基础部分 基础部分的顺序:基本语法,类相关的语法,内部类的语法,继承相关的语法,异常的语法,线程的语...
    子非鱼_t_阅读 31,779评论 18 399
  • 控制器1.文件名不需要加后缀,全部小写2.类名首字母大写,继承CI_Controller基类3.以下划线开头或者非...
    栋栋晓阅读 1,427评论 1 6
  • 一 没有玫瑰和拥抱 光是和你站在一起 我就觉得今晚月色很好 二 想见你一面 在明媚的春天 怎奈未来阴雨连绵 三 千...
    一叶蓝秋阅读 702评论 6 5
  • 1.isKindOfClass、isMemberOfClass、selector作用分别是什么 2.delegat...
    小笨憨阅读 190评论 0 0