概述和基本配置引數 配置ci:
配置基於htaccess的重定向
rewriteengine on
rewritecond $1 !^(index¥.php|images|robots¥.txt)
rewriterule ^(.*)$ /index.php/$1 [l]
任何除開 index.php,images, 和robots.txt 的 http 請求都當成對 index.php 檔案的請求。
增加 url 後 綴
配置後帶或不帶字尾都可以訪問
使用index.php的get方式訪問控制類
$config['enable_query_strings'] = true;
$config['controller_trigger'] = 'c';
$config['function_trigger'] = 'm';
訪問方式:index.php?c=controller&m=method
自定義的簡單的控制類
<?php
class blog extends controller
}?>
控制器的訪問和引數傳遞
定義預設控制器
控制器中的預定義方法
_remap() 方法:不管uri中呼叫的 方法是哪個,該請求都會被重定向到此方法
被覆蓋的方法名會作為引數傳遞進來,引數依次排列到後面
_output() 方法:類中任意函式的輸出結果都會交給此函式處理後再交給客戶瀏覽器
function _output($output);
檢視在控制器中載入特定檢視:$this->load->view('name');
name 是視**件的檔名,不包括.php 字尾。
$this->load->view('folder_name/file_name');
向檢視中傳遞動態資料:
$this->load->view('blogview', $data,$data2);
$data可以是陣列或者物件(類的示例);
檢視中使用php語法
模型引入model:$this->load->model('model_name');
一旦引入:可以使用裡面的函式:$this->model_name->function();
還可以指定model名:
$this->load->model('model_name', 'fubar');
$this->fubar->function();
模型被載入後不會自動建立資料庫連線,只會在被呼叫的時候才會
要在引入模型時建立資料庫連線,需要$this->load->model('model_name', '', true);
助手助手包含完成特定功能的一系列函式,匯入特定助手後即可以像使用php內建函式一樣使用ci助手提供的函式了
$this->load->helper('name');
載入多個助手:$this->load->helper( array('helper1', 'helper2', 'helper3') );
外掛程式與helper類似,但外掛程式只提供單一的功能,而helper提供一系列的功能
$this->load->plugin('name');
比如$this->load->plugin('captcha');載入的就是captcha_pi.php
$this->load->plugin( array('plugin1', 'plugin2', 'plugin3') );
ci庫載入庫:$this->load->library('class name');
建立自己的庫,要求,首字母大寫,
自定義庫中引用ci資源:get_instance() 函式
$ci =& get_instance();
$ci->load->helper('url');
$ci->load->library('session');
$ci->config->item('base_url');
使用ci管理 資料庫
在你的控制器的建構函式中新增:$this->load->scaffolding('marry_user_profile');
就可以通過訪問http://localhost/yourclass/zhougege來 管理你的資料庫了
ci錯誤處理
index.php中預設的是顯示所有錯誤: error_reporting(e_all);
log_message('level', 'message')函式,把錯誤資訊寫入錯誤日誌。你必須在第乙個引數中提供錯誤級別(三種),指出是哪種級別的錯誤(debug, error, info), 第二個引數是錯誤資訊
ci快取: 在控制器中開啟快取:$this->output->cache(n); n是快取時間,單位是秒
pycharm的安裝配置和簡單使用
1.pycharm的安裝和配置 2 基本設定 file setting project project interpreter,選擇之前文件安裝的python直譯器如下圖 file setting editor color scheme color scheme font 修改 框顯示字型如下圖 f...
saltstack的簡單安裝配置
系統環境 服務端和客戶端均為centos7,關閉防火牆和selinux 安裝master和minion root v72 yum.repos.d yum install salt master y root v72 yum.repos.d yum install salt minion y root...
簡單安裝配置SVN
安裝svn yum y install subversion orsudo apt get y install subversion 建立版本庫目錄 mkdir svndata 啟動svnserve d r svndata d 表示後台執行 r 指定根目錄是 svndata 建立乙個新的subver...