Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

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

2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report