99久久国产露脸精品麻豆,欧美日韩精品小说,亚洲免费在线美女视频,国产三级中文字幕,91极品国产情侣高潮对白,国产亚洲一区二区三区不卡片,欧美jizz精品欧美性,久久国产精品久久国产片

YZMPHP V2.8 更新框架DB操作類

袁志蒙 1866次瀏覽

摘要:YZMPHP V2.8 發(fā)布了,框架更新優(yōu)化了很多細(xì)節(jié)問(wèn)題,本文主要介紹更新的DB操作類,并介紹框架的新版本中如何查詢數(shù)據(jù)及使用,舊版本的文檔手冊(cè)請(qǐng)轉(zhuǎn)至 https://www.yzmcms.com/dongtai/37.html ,where 條件可以完成包括普通查詢、表達(dá)式...

【重要】這篇文檔內(nèi)容已棄用,請(qǐng)查看最新版的文檔https://www.yzmcms.com/dongtai/153.html

where方法的用法是YZMPHP框架查詢語(yǔ)言的精髓,可以完成包括普通查詢、表達(dá)式查詢、快捷查詢、區(qū)間查詢、組合查詢?cè)趦?nèi)的查詢操作,where方法的參數(shù)支持字符串和數(shù)組,我們建議為數(shù)組查詢。

字符串條件:

$db->where('status=1 and age>18')->select();

數(shù)組條件:

// 以下為YZMPHP V2.8新增的where條件語(yǔ)法,舊版鏈接:https://www.yzmcms.com/dongtai/37.html
$where['字段']  = '字段條件';
$where['字段1']  = array('表達(dá)式','字段條件1');
$where['字段2']  = array('表達(dá)式','字段條件2');
$where['字段3']  = array('表達(dá)式','字段條件3','可選參數(shù)(函數(shù)名)');

//第三個(gè)為可選參數(shù),第三個(gè)參數(shù)是一個(gè)函數(shù)名稱,是對(duì)“字段條件”做處理,例如:
$where['cms'] = ['neq', 'yzmcms', 'trim'];
$where['id'] = ['in', ['11','22','33'], 'intval'];
$db->where($where)->select();

// 條件或查詢(OR)
$db->where($where1, $where2, $where3)->select();

where方法還支持傳入多個(gè)參數(shù),以上這種多個(gè)where參數(shù)就組成了where或查詢,最終執(zhí)行結(jié)果為 where1 OR where2 OR where3,其中每個(gè)where既可以是數(shù)組也可以是字符串。


表達(dá)式含義(不分大小寫):

eq等于(=)

neq不等于(<>)

gt大于(>)

egt大于等于(>=)

lt小于(<)

elt小于等于(<=)

like模糊查詢

notlike(不在)模糊查詢

[not] in(不在)in 查詢

[not] between(不在)區(qū)間查詢


下面我們舉一些例子來(lái)說(shuō)明:

$where = [];

$where['cms'] = ['eq', 'yzmcms'];
// 等同于 $where['cms'] = 'yzmcms';

$where['cms'] = ['neq', 'yzmcms'];
// 等同于 $where['cms!='] = 'yzmcms';

$where['age'] = ['gt', '18'];
// 等同于 $where['age>'] = '18';

$where['age'] = ['egt', '18'];
// 等同于 $where['age>='] = '18';

$where['age'] = ['lt', '18'];
// 等同于 $where['age<'] = '18';

$where['age'] = ['elt', '18'];
// 等同于 $where['age<='] = '18';

$where['cms'] = ['like', '%yzmcms%'];
// 等同于 $where['cms'] = '%yzmcms%';

// 新版支持的語(yǔ)法查詢:
$where['cms'] = ['notlike', '%yzmcms%'];

$where['id'] = ['in', ['11','22','33']];
$where['id'] = ['in', ['11','22','33'], 'intval'];

$where['id'] = ['notin', ['11','22','33']];
$where['id'] = ['notin', ['11','22','33'], 'intval'];

$where['id'] = ['between', ['1','99']];
$where['id'] = ['between', ['1','99'], 'intval'];

$where['id'] = ['notbetween', ['1','99']];
$where['id'] = ['notbetween', ['1','99'], 'intval'];


// 執(zhí)行查詢操作并打印結(jié)果
$res = $db->where($where)->select();
P($res);

// 打印生成的SQL
$db->lastsql();


新版還更新了query方法,可根據(jù)SQL類型返回 arraybool ,并新增了第二個(gè)參數(shù),如果SQL為查詢類型,則第二個(gè)參數(shù)則可以控制是否返回二維數(shù)組,默認(rèn)查詢查詢返回二維數(shù)組,false則返回一維數(shù)組。

// 其中[yzmcms_]表示通用表前綴,無(wú)需修改
$res = $db->query("select * from yzmcms_admin"); 
$res = $db->query("select * from yzmcms_admin", false); 

P($res);


隨機(jī)內(nèi)容

表情

共0條評(píng)論
  • 這篇文章還沒(méi)有收到評(píng)論,趕緊來(lái)?yè)屔嘲l(fā)吧~