您当前的位置: 首页 > 慢生活 > 程序人生 网站首页程序人生
webman-查詢構造器-獲取所有行、獲取指定列
发布时间:2022-02-01 19:55:41编辑:雪饮阅读()
控制器中如:
public function index(Request $request)
{
//獲取所有行
$allLine = Db::table('ecms_news')->get();
$allLine0=$allLine[0];
//獲取指定列及指定字段別名
$cloum = Db::table('ecms_news')->select('classid', 'id as xyid')->get();
$cloum0=$cloum[0];
var_dump(compact("allLine0","cloum0"));
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) {
["allLine0"]=>
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)
}
["cloum0"]=>
object(stdClass)#2497 (2) {
["classid"]=>
int(27)
["xyid"]=>
int(3131)
}
}
关键字词:webman,查詢,構造,器,獲取,所有,行,指定,列