您当前的位置: 首页 > 慢生活 > 程序人生 网站首页程序人生
webman-查詢構造器-獲取一行,獲取一列
发布时间:2022-02-01 20:40:54编辑:雪饮阅读()
webman中獲取一行和獲取一列,這裏默認自然是以mysql為例,則控制器中如:
public function index(Request $request)
{
//獲取一行
$row = Db::table('ecms_news')->where('id',86)->first();
//獲取一列
$usernames = Db::table('ecms_news')->pluck('username');
$usernames0=$usernames[0];
var_dump(compact("row","usernames0"));
return response("ok");
}
然後實例運行后被訪問時:
[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(2) {
["row"]=>
object(stdClass)#53 (34) {
["id"]=>
int(86)
["classid"]=>
int(67)
["ttid"]=>
int(0)
["onclick"]=>
int(4227)
["plnum"]=>
int(0)
["totaldown"]=>
int(0)
["newspath"]=>
string(0) ""
["filename"]=>
string(2) "86"
["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(1423470979)
["lastdotime"]=>
int(1425343586)
["havehtml"]=>
int(1)
["groupid"]=>
int(0)
["userfen"]=>
int(0)
["titlefont"]=>
string(0) ""
["titleurl"]=>
string(37) "/mobanfenxiang/gerenbokemoban/86.html"
["stb"]=>
int(1)
["fstb"]=>
int(1)
["restb"]=>
int(1)
["keyboard"]=>
string(0) ""
["title"]=>
string(39) "个人博客模板《世界杯来袭》"
["newstime"]=>
int(1423470931)
["titlepic"]=>
string(84) "/d/file/mobanfenxiang/gerenbokemoban/2015-02-09/ba82931d7ee52bc0a6d353385d1e63c4.jpg"
["ftitle"]=>
string(0) ""
["smalltext"]=>
string(241) " 个人博客模板《世界杯来袭》,博客模板色调以绿色和黄色为主色、布局简单随意,以世界杯为主题,绿色清新、黄色活泼、醒目... 此模板暂不提供html下载,喜欢的朋友可以下载"
["diggtop"]=>
int(0)
}
["usernames0"]=>
string(6) "雪饮"
}
关键字词:webman,查詢構造器,獲取一行,獲取一列