① php ci框架要怎麼用,我在CodeIgniter 中國里下載了CodeIgniter_2.1.3 ,要怎麼使用啊,誰來點詳細的步驟
解壓到web根目錄下。例如 web根目錄下的ci目錄。
地址欄中輸入 localhost/ci
就可以看到第一個welcome頁面了。
在ci/app/controllers下放的是控制器類,每個類的方法對應一個web頁面。
② Php的ci框架怎麼做後台管理系統一些按鈕怎麼寫出來的!
ci框架只提供一系列後端代碼的擴展以及管理,你想要寫個後台管理系統需要自己寫,不像drupal可以直接生成代碼。
③ php CI框架模糊查詢寫法
like 模糊查詢 ci框架
[php]代碼庫
view sourceprint?
$this->db->like('title', 'match', 'before');
// 生成: WHERE title LIKE '%match'
$this->db->like('title', 'match', 'after');
// 生成: WHERE title LIKE 'match%'
$this->db->like('title', 'match', 'both');
// 生成: WHERE title LIKE '%match%'
④ PHP CI框架怎麼傳參數和去參數值
例如:document/index.php/send/sendlist/index2/1143
獲取:$this->uri->segment(n) 獲取第n個參數
1. send
2.sendlist
3.index2
4.1143
$this->uri->segment(4) 即獲取到id的值了
⑤ 有人熟悉php的ci框架么
你好,我有參與過CI框架的項目開發工作,你是想問如何學習CI框架和CI框架的流行程度吧。
學習CI框架,我建議你可以使用視頻學習,也可以直接觀看CI框架的手冊進行學習。這樣效率其實會更高。對於CI框架的流行程度,其實不管在國內還是國外,CI還是屬於比較流行的PHP框架。就業前景也不錯。
⑥ php ci框架中如何定義model
手冊里應該很詳情了把
在application下models下建立一個文件
在ci2里文件名應為類名的首字母小寫形式例如類為User則文件名應該是user.php
ci3里要求是大寫User=>User.php
下面是一個最簡單的model
classUser_modelextendsCI_Model{
publicfunction__construct(){
parent::__construct();
}
}
文件名ci2user_model.php
ci3User_model.php
⑦ PHP CI框架修改數據的方法
CI框架下的PHP增刪改查總結:
controllers下的 cquery.php文件
[php] view plain
<?php
class CQuery extends Controller {
//構造函數
function CQuery() {
parent::Controller();
// $this->load->database();
}
function index() {
//調用model 其中train為外層文件夾 MQuery為model名稱 queryList為重命名
$this->load->model('train/MQuery','queryList');
//獲得返回的結果集 這里確定調用model中的哪個方法
$result = $this->queryList->queryList();
//將結果集賦給res
$this->smarty->assign('res',$result);
//跳轉到顯示頁面
$this->smarty->view('train/vquery.tpl');
}
//進入新增頁面
function addPage() {
$this->smarty->view('train/addPage.tpl');
}
//新增
function add() {
//獲得前台數據
//用戶名
$memberName = $this->input->post('memberName');
//密碼
$password = $this->input->post('password');
//真實姓名
$userRealName = $this->input->post('userRealName');
//性別
$sex = $this->input->post('sex');
//出生日期
$bornDay = $this->input->post('bornDay');
//e_mail
$eMail = $this->input->post('eMail');
//密碼問題
$question = $this->input->post('question');
//密碼答案
$answer = $this->input->post('answer');
//調用model
$this->load->model('train/MQuery','addRecord');
//向model中的addRecord傳值
$result = $this->addRecord->addRecord($memberName,$password,$userRealName,$sex,$bornDay,$eMail,$question,$answer);
//判斷返回的結果,如果返回true,則調用本頁的index方法,不要寫 $result == false 因為返回的值未必是false 也有可能是""
if ($result) {
$this->index();
} else {
echo "add failed.";
}
}
//刪除
function deletePage() {
//獲得ID
$deleteID = $this->uri->segment(4);
//調用model
$this->load->model('train/MQuery','delRecord');
//將值傳入到model的delRecord方法中
$result = $this->delRecord->delRecord($deleteID);
//判斷返回值
if ($result) {
$this->index();
} else {
echo "delect failed.";
}
}
//修改先查詢
function changePage() {
$changeID = $this->uri->segment(4);
$this->load->model('train/MQuery','changeRecord');
$result = $this->changeRecord->changeRecord($changeID);
//將結果集賦給res
$this->smarty->assign('res',$result);
//跳轉到顯示頁面
$this->smarty->view('train/changePage.tpl');
}
//修改
function change() {
//獲得前台數據
//ID
$ID = $this->input->post('id');
//用戶名
$memberName = $this->input->post('memberName');
//密碼
$password = $this->input->post('password');
//真實姓名
$userRealName = $this->input->post('userRealName');
//性別
$sex = $this->input->post('sex');
//出生日期
$bornDay = $this->input->post('bornDay');
//e_mail
$eMail = $this->input->post('eMail');
//密碼問題
$question = $this->input->post('question');
//密碼答案
$answer = $this->input->post('answer');
//調用model
$this->load->model('train/MQuery','change');
//向model中的change傳值
$result = $this->change->change($ID,$memberName,$password,$userRealName,$sex,$bornDay,$eMail,$question,$answer);
//判斷返回的結果,如果返回true,則調用本頁的index方法,不要寫 $result == false 因為返回的值未必是false 也有可能是""
if ($result) {
$this->index();
} else {
echo "change failed.";
}
}
}
models中的 mquery.php 文件
[php] view plain
<?php
class MQuery extends Model {
//構造函數
function MQuery() {
parent::Model();
//連接資料庫
$this->load->database();
}
//查詢列表
function queryList() {
//防止select出的數據存在亂碼問題
//mysql_query("SET NAMES GBK");
//SQL語句
$sql = "SELECT ID,member_name,sex,e_mail FROM user_info_t";
//執行SQL
$rs = $this->db->query($sql);
//將查詢結果放入到結果集中
$result = $rs->result();
//關閉資料庫
$this->db->close();
//將結果集返回
return $result;
}
//新增
function addRecord($memberName,$password,$userRealName,$sex,$bornDay,$eMail,$question,$answer) {
//防止select出的數據存在亂碼問題
//mysql_query("SET NAMES GBK");
//SQL語句
$sql = "INSERT INTO user_info_t (member_name,password,user_real_name,sex,born_day,e_mail,question,answer) " .
"VALUES ('$memberName','$password','$userRealName','$sex','$bornDay','$eMail','$question','$answer')";
//執行SQL
$result = $this->db->query($sql);
//關閉資料庫
$this->db->close();
//返回值
return $result;
}
//刪除
function delRecord($deleteID) {
//防止select出的數據存在亂碼問題
//mysql_query("SET NAMES GBK");
$sql = "DELETE FROM user_info_t WHERE ID = $deleteID";
$result = $this->db->query($sql);
$this->db->close();
return $result;
}
//修改前查詢
function changeRecord($changeID) {
//防止select出的數據存在亂碼問題
//mysql_query("SET NAMES GBK");
$sql = "SELECT ID,member_name,password,user_real_name,sex,born_day,e_mail,question,answer FROM user_info_t WHERE ID = $changeID";
//執行SQL
$rs = $this->db->query($sql);
$result = $rs->row();//$result = $rs[0]
//關閉資料庫
$this->db->close();
//將結果集返回
return $result;
}
//修改
function change($ID,$memberName,$password,$userRealName,$sex,$bornDay,$eMail,$question,$answer) {
//防止select出的數據存在亂碼問題
//mysql_query("SET NAMES GBK");
//SQL語句
$sql = "update user_info_t set member_name = '$memberName',password = '$password', user_real_name = '$userRealName'," .
"sex = '$sex',born_day = '$bornDay',e_mail = '$eMail',question = '$question',answer = '$answer'" .
"where ID = $ID";
//執行SQL
$result = $this->db->query($sql);
//關閉資料庫
$this->db->close();
//返回值
return $result;
}
}
views 下的 addPage.tpl文件
[php] view plain
<html>
<head>
</head>
<body><form action="{{site_url url='train/cquery/add'}}" method="post">
<table border='1'>
<tr>
<td>用戶名</td>
<td><input type="text" class="text" name="memberName" id="memberName"/></td>
</tr>
<tr>
<td>密碼</td>
<td><input type="text" class="text" name="password" id="password"/></td>
</tr>
<tr>
<td>真實姓名</td>
<td><input type="text" class="text" name="userRealName" id="userRealName"/></td>
</tr>
<tr>
<td>性別</td>
<td><input type="text" class="text" name="sex" id="sex"/></td>
</tr>
<tr>
<td>出生日期</td>
<td><input type="text" class="text" name="bornDay" id="bornDay"/></td>
</tr>
<tr>
<td>e_mail</td>
<td><input type="text" class="text" name="eMail" id="eMail"/></td>
</tr>
<tr>
<td>密碼問題</td>
<td><input type="text" class="text" name="question" id="question"/></td>
</tr>
<tr>
<td>密碼答案</td>
<td><input type="text" class="text" name="answer" id="answer"/></td>
</tr>
</table>
<table>
<tr>
<td><input type="submit" class="button" name="OK" value="提交" />
</td>
</tr>
</table></form>
</body>
</html>
⑧ php 項目 如何include CI框架里的東西
CI框架需要include調用的無非3種文件:
封裝的類: $this->load->library('文件名');
helper的function: $this->load->helper('文件名');
model數據層 $this->load->model('文件名');
如果還不滿足 就直接寫include調
⑨ 用php的CI框架怎麼寫登錄和注冊
在view里寫login.php,在controller里寫插入資料庫的代碼,同時調用。
⑩ 如何學習CI框架
都是要實踐的,而且要由淺入深。建議去找找一些人際開發的簡單的CI功能,比如一些進度管理系統啊,社區啊之類的,多看看system下面的library和helper,了解CI基礎的功能函數,再試著接觸core文件夾下的核心文件,你會運用自如的。