-
update更新
$update['scroe']='60';
$where['id']=1;
$data=M('User')->where($where)-save($update);
查看全部 -
select查詢
1、直接使用字符串進行查詢
$data=M('User')->where('id=1')->select();
2、使用數(shù)組方式進行查詢
$where['Username']='xiaoming';
$where['id']=2;
$where['_logic']='or';//不加為默認AND,加上中連接符為OR
$data=M('user')->where($where)->select();
3、表達式查詢 eq neq egt gt lt elt between in like not between not in
$where['字段名']=array(表達式,查詢條件);
$where['id']=array('lt',3);
$where['user_name']=array('like',array('%ming','xiao%'));
4、區(qū)間查詢
$where['id']=array(array('lt',1),array('gt',2),'or');
$data=M('User')->where($where)->select();
5、混合用法
$where['id']=array('gt',10);
$where['_string']=' score >10';//加字符串
$data=M('User')->where($where)->select();
6、統(tǒng)計用法
/*
*count 統(tǒng)計數(shù)量 可選
*max 獲取最大值 必須必 需要傳入統(tǒng)計的字段名
*min 獲取最大值 必須必 需要傳入統(tǒng)計的字段名
*avg 獲取最大值 必須必 需要傳入統(tǒng)計的字段名
*sum 獲取最大值 必須必 需要傳入統(tǒng)計的字段名
*/
$data=M('User')->count();
$data=M('User')->sum('id');
查看全部 -
數(shù)據(jù)庫,添加數(shù)據(jù)
查看全部 -
數(shù)據(jù)庫實例化模型
3、公共模型
4、空模型
查看全部 -
數(shù)據(jù)庫實例化模型
1、基礎(chǔ)模型model
2、自定義模型
查看全部 -
數(shù)據(jù)庫配置
查看全部 -
單個參數(shù)調(diào)試 trace('name',C('name'));
會在游覽器調(diào)試欄顯示
查看全部 -
測試程序運行的時間
$G('run')
程序開始
程序結(jié)束
echo G('run','end')//毫秒
查看全部 -
1、新建項目調(diào)試文件,在conf文件夾下創(chuàng)建debug.php
2、開啟調(diào)試,trace
'SHOW_PAGE_TRACE'=>true
查看全部 -
三元運算符
查看全部 -
區(qū)間標簽
range標簽type只能用in ,notin不能用between? ,notbetween
查看全部 -
比較標簽
eq =? neq? !=? ?等
查看全部 -
for循環(huán)使用
comparison='elt'
默認小于等
查看全部 -
模板中使用,(等于,不等于,大于,大于等于,小于,小于等于,恒等于,不恒等于)
eq? ?=
neq? !=
gt? >
egt>=
lt<
elt<=
heq ===
nheq !===
查看全部 -
volist和foreach循環(huán)
volist可以截取數(shù)據(jù)
foreach不可
查看全部
舉報