Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Weed3-2.3.2. What are the conditions of the query?

Shulou Source: shulou.com Published: 2022-06-02 03:41:54 10月03日 Update

This article mainly introduces "weed3-2.3.2. What are the query conditions", in the daily operation, I believe many people in weed3-2.3.2. The editor consulted all kinds of data and sorted out simple and easy-to-use methods of operation, hoping to help you answer the question of "weed3-2.3.2. What are the conditions of the query?" Next, please follow the editor to study!

Weed3 A miniature ORM framework

Source code: https://github.com/noear/weed3 source code: https://gitee.com/noear/weed3

Inquiry is a troublesome topic. Fortunately, this condition will be relatively simple.

Single table conditional query (with simple nature can be spelled into complex ones)

/ / the condition construction of weed3 is quite free String mobile= "111111; db.table (" test ") .where (" mobile=? ", mobile). And (). Begin (" sex=? ", 1). Or (" sex=2 "). End () .limit (20) .select (" * "). GetMapList () db.table (" test ") .where (" mobile=? ", mobile) .and (" (sex=? ") OR sex=2) ", 1) .limit (20) .select (" * ") .getMapList () db.table (" test ") .where (" mible=? ") AND (sex=1 OR sex=2) ", mobile) .limit (20) .select (" * ") / / above, the effect is the same. Because it is very free, it is easy to use (there is also a view that it is difficult to control)

Sometimes some conditions need to be controlled dynamically

/ / this example, int type=ctx.paramAsInt ("type", 0); String key=ctx.param ("key"); int date_start=ctx.paramAsInt ("date_start", 0); int date_end=ctx.paramAsInt ("date_end", 0); DbTableQuery qr = db.table ("test"). Where ("1x1"); if (type > 0) {qr.and ("type=?", type) } if (key! = null) {qr.and ('"title LIKE?", key+ "%");} if (date_start > 0 & & date_end > 0) {qr.and ("(date > =?) AND date ", 12) .select (" u.name.b.* ")

How about other related queries? (e. G. full join)

/ / because not all databases support full join, so. Db.table ("user u") .append ("FULL JOIN user_book b"). On ("u.id = b.user_id") .select ("u.name.dint b.*") / / .append (..) You can add any content of the interface here, about "weed3-2.3.2. What are the conditions of the query" study is over, I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Tags: Conditions query learning freedom more source code association help control complex practical next content dynamic background common interface effect data database Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple Shulou Technology MariaDB NVidia macOS