您当前的位置: 首页 > 慢生活 > 程序人生 网站首页程序人生
webman-查詢構造器-whereColumn 的用法
发布时间:2022-02-05 11:46:24编辑:雪饮阅读()
實例:
public function index(Request $request)
{
ini_set('memory_limit','4096M');
// whereColumn方法用于比较两个字段的值是否相等
$data = Db::table('ecms_news')
->whereColumn('truetime', 'lastdotime')
->get();
$whereColumn=isset($data[0]) ? $data[0]:[];
//你也可以传入一个比较运算符
$data = Db::table('ecms_news')
->whereColumn('truetime', '>','lastdotime')
->get();
$whereColumnGt=isset($data[0]) ? $data[0]:[];
//whereColumn 方法也可以传递数组
$data = Db::table('ecms_news')
->whereColumn([
['truetime', '=', 'lastdotime'],
['onclick', '>', 'id'],
])
->get();
$whereColumnArray=isset($data[0]) ? $data[0]:[];
$all=compact("whereColumn","whereColumnGt","whereColumnArray");
var_dump($all);
return response("ok");
}
構造的sql:
select * from `phome_ecms_news` where `truetime` = `lastdotime`
select * from `phome_ecms_news` where `truetime` > `lastdotime`
select * from `phome_ecms_news` where (`truetime` = `lastdotime` and `onclick` > `id`)
實例被請求時:
[root@localhost webman]# /usr/local/php734/bin/php -c /usr/local/php734/lib/php.ini start.php start
Workerman[start.php] start in DEBUG mode
----------------------------------------- WORKERMAN -----------------------------------------
Workerman version:4.0.26 PHP version:7.3.4
------------------------------------------ WORKERS ------------------------------------------
proto user worker listen processes status
tcp root webman http://0.0.0.0:8787 4 [OK]
tcp root monitor none 1 [OK]
---------------------------------------------------------------------------------------------
Press Ctrl+C to stop. Start success.
訪問了全局中間件!
array(3) {
["whereColumn"]=>
object(stdClass)#53 (37) {
["id"]=>
int(116)
["classid"]=>
int(84)
["ttid"]=>
int(0)
["onclick"]=>
int(69)
["plnum"]=>
int(0)
["totaldown"]=>
int(0)
["newspath"]=>
string(10) "2015-02-15"
["filename"]=>
string(3) "116"
["userid"]=>
int(1)
["username"]=>
string(6) "雪饮"
["firsttitle"]=>
int(0)
["isgood"]=>
int(0)
["ispic"]=>
int(1)
["istop"]=>
int(0)
["isqf"]=>
int(0)
["ismember"]=>
int(0)
["isurl"]=>
int(0)
["truetime"]=>
int(1423990307)
["lastdotime"]=>
int(1423990307)
["havehtml"]=>
int(1)
["groupid"]=>
int(0)
["userfen"]=>
int(0)
["titlefont"]=>
string(0) ""
["titleurl"]=>
string(48) "/manshenghuo/chengxurensheng/2015-02-15/116.html"
["stb"]=>
int(1)
["fstb"]=>
int(1)
["restb"]=>
int(1)
["keyboard"]=>
string(0) ""
["title"]=>
string(45) "Photoshop制作透明浮雕水印文字教程"
["newstime"]=>
int(1423990203)
["titlepic"]=>
string(83) "/d/file/manshenghuo/chengxurensheng/2015-02-15/ac6844fd89ebf0ce8636226e061badee.jpg"
["ftitle"]=>
string(0) ""
["smalltext"]=>
string(248) "今日就抽空为各位好好介绍一下,到底要怎么样正确来使用图层面板中的填充,本教程用透明浮雕字的制作来作解说 图层面板中不难看到填充这东东,但应该有不少朋友视它而不见吧"
["diggtop"]=>
int(0)
["push_weixin_material"]=>
int(0)
["push_baidu_last_time"]=>
int(0)
["push_weixin_material_last_time"]=>
int(0)
}
["whereColumnGt"]=>
array(0) {
}
["whereColumnArray"]=>
object(stdClass)#2212 (37) {
["id"]=>
int(87)
["classid"]=>
int(76)
["ttid"]=>
int(0)
["onclick"]=>
int(196)
["plnum"]=>
int(0)
["totaldown"]=>
int(0)
["newspath"]=>
string(10) "2015-02-10"
["filename"]=>
string(2) "87"
["userid"]=>
int(1)
["username"]=>
string(6) "雪饮"
["firsttitle"]=>
int(0)
["isgood"]=>
int(1)
["ispic"]=>
int(1)
["istop"]=>
int(0)
["isqf"]=>
int(0)
["ismember"]=>
int(0)
["isurl"]=>
int(0)
["truetime"]=>
int(1423568007)
["lastdotime"]=>
int(1423568007)
["havehtml"]=>
int(1)
["groupid"]=>
int(0)
["userfen"]=>
int(0)
["titlefont"]=>
string(0) ""
["titleurl"]=>
string(42) "/xuewuzhijing/xindebiji/2015-02-10/87.html"
["stb"]=>
int(1)
["fstb"]=>
int(1)
["restb"]=>
int(1)
["keyboard"]=>
string(0) ""
["title"]=>
string(60) "【匆匆那些年】总结个人博客经历的这四年…"
["newstime"]=>
int(1423567877)
["titlepic"]=>
string(78) "/d/file/xuewuzhijing/xindebiji/2015-02-10/ab59489ace286b26458f0afff940d2fe.jpg"
["ftitle"]=>
string(0) ""
["smalltext"]=>
string(265) " 博客从最初的域名购买,到上线已经有四年的时间了,这四年的时间,有笑过,有怨过,有悔过,有执着过,也有放弃过…但最后还是坚持了下来,时间如此匆匆,等再回过头已来不及去弥补"
["diggtop"]=>
int(0)
["push_weixin_material"]=>
int(0)
["push_baidu_last_time"]=>
int(0)
["push_weixin_material_last_time"]=>
int(0)
}
}
关键字词:webman,查詢構造器,whereColumn
相关文章
- webman-查詢構造器-whereDate,whereMonth,whereDay,wh
- webman-查詢構造器-whereNull ,whereNotNull,orWhereN
- webman-查詢構造器-whereIn、whereNotIn、orWhereIn
- webman-查詢構造器-whereBetween 與 orWhereBetween
- webman-查詢構造器-閉包查詢、whereBetween 與 orWher
- webman-查詢構造器-條件數組、where與orWhere
- webman-查詢構造器-where語句-等於、大於等於、不等於
- webman-查詢構造器-Union 语句-合并結果集
- webman-查詢構造器-join語句-交叉連接 cross join
- webman-查詢構造器-join語句-左右連接(leftJoin、righ