Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to understand weed3-2.2. Insert and update

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

This article introduces the knowledge of "how to understand weed3-2.2. insert and update". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Weed3 A miniature ORM framework

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

This article focuses on inserting and updating assignments.

Support for general assignment

String mobile= "xxx"; / / my mobile phone number cannot write db.table ("test") .set ("mobile", mobile) / / variable assignment. Set ("sex", 1) / / constant assignment .insert ()

Sql attached values are supported (this is a convenient * *). If the value starts with: $, it means that it is followed by a SQL code (no spaces can occur and is less than 100 characters). Otherwise, it is regarded as a normal string value), as follows:

/ for example, the current time assignment db.table ("test"). Set ("log_time", "$NOW ()"). Insert (); / / another example: field plus 1 appended value db.table ("test"). Set ("num", "$num+1") .where ("id=?", 1). Update () / / another example: batch update db.table ("test"). Set ("txt_md5", "$MD5 (txt)") .where ("id >?") based on the md5 of another field. AND id

Tags: Updates support fields functions code global content characters situations data datasheets more source code knowledge practical general secure learned and then variables Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple vpn macOS NVidia MariaDB