CI框架
-
介紹
優(yōu)雅的CodeIgniter汞窗,稱之為CI框架蒜茴,CodeIgniter 是一個小巧但功能強大的 PHP 框架,作為一個簡單而“優(yōu)雅”的工具包牌柄,它可以為開發(fā)者們建立功能完善的 Web 應(yīng)用程序多搀。
-
安裝
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 ) );
傳遞參數(shù)到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方式的數(shù)據(jù)
-
刪
public function del($id) { $this->db->delete("ci_student", [ "id" => $id ]); }
這樣的寫法酗昼,就是獲取get方式的數(shù)據(jù)
-
增
$name = $this->input->post('name'); $age = $this->input->post('age'); $this->db->insert("ci_student", [ "name" => $name, "age" => $age ]);