您当前的位置: 首页 > 慢生活 > 程序人生 网站首页程序人生
webman-查詢構造器-where語句-等於、大於等於、不等於、模糊查詢
发布时间:2022-02-04 21:52:48编辑:雪饮阅读()
webman中的where語句的使用,這裏以等於的兩種寫法,大於等於、不等於以及模糊查詢的寫法再控制器中的實例如:
public function index(Request $request)
{
ini_set('memory_limit','4096M');
//查詢id等於114的數據
$idEquals114 = Db::table('ecms_news')->where('id', '=', 114)->get();
$idEquals1140=$idEquals114[0];
//查詢id等於114的數據
$ellipsisEqualsSymbolsIdEquals114=Db::table('ecms_news')->where('id', 114)->get();
$ellipsisEqualsSymbolsIdEquals1140=$ellipsisEqualsSymbolsIdEquals114[0];
//查詢id大於等於100的數據
$idgtEquals100 = Db::table('ecms_news')
->where('id', '>=', 100)
->get();
$idgtEquals1000=$idgtEquals100[0];
//查詢id不等於100的數據
$idnotEquals100 = Db::table('ecms_news')
->where('id', '<>', 100)
->get();
$idnotEquals1000=$idnotEquals100[0];
//查詢username字段值中以"雪"開頭的
$usernameStartWith_Snow_ = Db::table('ecms_news')
->where('username', 'like', '雪%')
->get();
$usernameStartWith_Snow_0=$usernameStartWith_Snow_[0];
$all=compact("idEquals1140","ellipsisEqualsSymbolsIdEquals1140","idgtEquals1000","idnotEquals1000","usernameStartWith_Snow_0");
var_dump($all);
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(5) {
["idEquals1140"]=>
object(stdClass)#53 (37) {
["id"]=>
int(114)
["classid"]=>
int(83)
["ttid"]=>
int(0)
["onclick"]=>
int(62)
["plnum"]=>
int(0)
["totaldown"]=>
int(0)
["newspath"]=>
string(0) ""
["filename"]=>
string(3) "114"
["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(1423920308)
["lastdotime"]=>
int(1425445123)
["havehtml"]=>
int(1)
["groupid"]=>
int(0)
["userfen"]=>
int(0)
["titlefont"]=>
string(0) ""
["titleurl"]=>
string(30) "/manshenghuo/xinshang/114.html"
["stb"]=>
int(1)
["fstb"]=>
int(1)
["restb"]=>
int(1)
["keyboard"]=>
string(0) ""
["title"]=>
string(30) "一个程序员的爱情故事"
["newstime"]=>
int(1423920134)
["titlepic"]=>
string(76) "/d/file/manshenghuo/xinshang/2015-02-14/01e4753ff30b6bf0838b6e55cbe88c39.jpg"
["ftitle"]=>
string(35) "程序员,爱情,雪饮个人博客"
["smalltext"]=>
string(170) " //一个程序员的爱情故事 public class MyLoveStory { public static void Main(string[] args) { //The ForeStory int result"
["diggtop"]=>
int(0)
["push_weixin_material"]=>
int(0)
["push_baidu_last_time"]=>
int(0)
["push_weixin_material_last_time"]=>
int(0)
}
["ellipsisEqualsSymbolsIdEquals1140"]=>
object(stdClass)#55 (37) {
["id"]=>
int(114)
["classid"]=>
int(83)
["ttid"]=>
int(0)
["onclick"]=>
int(62)
["plnum"]=>
int(0)
["totaldown"]=>
int(0)
["newspath"]=>
string(0) ""
["filename"]=>
string(3) "114"
["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(1423920308)
["lastdotime"]=>
int(1425445123)
["havehtml"]=>
int(1)
["groupid"]=>
int(0)
["userfen"]=>
int(0)
["titlefont"]=>
string(0) ""
["titleurl"]=>
string(30) "/manshenghuo/xinshang/114.html"
["stb"]=>
int(1)
["fstb"]=>
int(1)
["restb"]=>
int(1)
["keyboard"]=>
string(0) ""
["title"]=>
string(30) "一个程序员的爱情故事"
["newstime"]=>
int(1423920134)
["titlepic"]=>
string(76) "/d/file/manshenghuo/xinshang/2015-02-14/01e4753ff30b6bf0838b6e55cbe88c39.jpg"
["ftitle"]=>
string(35) "程序员,爱情,雪饮个人博客"
["smalltext"]=>
string(170) " //一个程序员的爱情故事 public class MyLoveStory { public static void Main(string[] args) { //The ForeStory int result"
["diggtop"]=>
int(0)
["push_weixin_material"]=>
int(0)
["push_baidu_last_time"]=>
int(0)
["push_weixin_material_last_time"]=>
int(0)
}
["idgtEquals1000"]=>
object(stdClass)#57 (37) {
["id"]=>
int(114)
["classid"]=>
int(83)
["ttid"]=>
int(0)
["onclick"]=>
int(62)
["plnum"]=>
int(0)
["totaldown"]=>
int(0)
["newspath"]=>
string(0) ""
["filename"]=>
string(3) "114"
["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(1423920308)
["lastdotime"]=>
int(1425445123)
["havehtml"]=>
int(1)
["groupid"]=>
int(0)
["userfen"]=>
int(0)
["titlefont"]=>
string(0) ""
["titleurl"]=>
string(30) "/manshenghuo/xinshang/114.html"
["stb"]=>
int(1)
["fstb"]=>
int(1)
["restb"]=>
int(1)
["keyboard"]=>
string(0) ""
["title"]=>
string(30) "一个程序员的爱情故事"
["newstime"]=>
int(1423920134)
["titlepic"]=>
string(76) "/d/file/manshenghuo/xinshang/2015-02-14/01e4753ff30b6bf0838b6e55cbe88c39.jpg"
["ftitle"]=>
string(35) "程序员,爱情,雪饮个人博客"
["smalltext"]=>
string(170) " //一个程序员的爱情故事 public class MyLoveStory { public static void Main(string[] args) { //The ForeStory int result"
["diggtop"]=>
int(0)
["push_weixin_material"]=>
int(0)
["push_baidu_last_time"]=>
int(0)
["push_weixin_material_last_time"]=>
int(0)
}
["idnotEquals1000"]=>
object(stdClass)#2632 (37) {
["id"]=>
int(114)
["classid"]=>
int(83)
["ttid"]=>
int(0)
["onclick"]=>
int(62)
["plnum"]=>
int(0)
["totaldown"]=>
int(0)
["newspath"]=>
string(0) ""
["filename"]=>
string(3) "114"
["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(1423920308)
["lastdotime"]=>
int(1425445123)
["havehtml"]=>
int(1)
["groupid"]=>
int(0)
["userfen"]=>
int(0)
["titlefont"]=>
string(0) ""
["titleurl"]=>
string(30) "/manshenghuo/xinshang/114.html"
["stb"]=>
int(1)
["fstb"]=>
int(1)
["restb"]=>
int(1)
["keyboard"]=>
string(0) ""
["title"]=>
string(30) "一个程序员的爱情故事"
["newstime"]=>
int(1423920134)
["titlepic"]=>
string(76) "/d/file/manshenghuo/xinshang/2015-02-14/01e4753ff30b6bf0838b6e55cbe88c39.jpg"
["ftitle"]=>
string(35) "程序员,爱情,雪饮个人博客"
["smalltext"]=>
string(170) " //一个程序员的爱情故事 public class MyLoveStory { public static void Main(string[] args) { //The ForeStory int result"
["diggtop"]=>
int(0)
["push_weixin_material"]=>
int(0)
["push_baidu_last_time"]=>
int(0)
["push_weixin_material_last_time"]=>
int(0)
}
["usernameStartWith_Snow_0"]=>
object(stdClass)#5221 (37) {
["id"]=>
int(114)
["classid"]=>
int(83)
["ttid"]=>
int(0)
["onclick"]=>
int(62)
["plnum"]=>
int(0)
["totaldown"]=>
int(0)
["newspath"]=>
string(0) ""
["filename"]=>
string(3) "114"
["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(1423920308)
["lastdotime"]=>
int(1425445123)
["havehtml"]=>
int(1)
["groupid"]=>
int(0)
["userfen"]=>
int(0)
["titlefont"]=>
string(0) ""
["titleurl"]=>
string(30) "/manshenghuo/xinshang/114.html"
["stb"]=>
int(1)
["fstb"]=>
int(1)
["restb"]=>
int(1)
["keyboard"]=>
string(0) ""
["title"]=>
string(30) "一个程序员的爱情故事"
["newstime"]=>
int(1423920134)
["titlepic"]=>
string(76) "/d/file/manshenghuo/xinshang/2015-02-14/01e4753ff30b6bf0838b6e55cbe88c39.jpg"
["ftitle"]=>
string(35) "程序员,爱情,雪饮个人博客"
["smalltext"]=>
string(170) " //一个程序员的爱情故事 public class MyLoveStory { public static void Main(string[] args) { //The ForeStory int result"
["diggtop"]=>
int(0)
["push_weixin_material"]=>
int(0)
["push_baidu_last_time"]=>
int(0)
["push_weixin_material_last_time"]=>
int(0)
}
}
关键字词:webman,查詢,構造器,where語句,等於,大於,不,模糊