pub struct Db { /* private fields */ }Expand description
快捷查询入口(think-orm Db::name() 风格)
不要求定义 Model,仅靠表名 + 方言即可生成 SQL。
Implementations§
Source§impl Db
impl Db
Sourcepub fn where_cond(self, condition: impl Into<String>) -> Self
👎Deprecated since 1.3.0: P0-2: 字符串拼接存在 SQL 注入风险,请使用 where_eq/where_ne/where_gt/where_lt/where_like 等参数化方法
pub fn where_cond(self, condition: impl Into<String>) -> Self
P0-2: 字符串拼接存在 SQL 注入风险,请使用 where_eq/where_ne/where_gt/where_lt/where_like 等参数化方法
WHERE 条件(AND)— 字符串拼接,存在 SQL 注入风险
⚠️ 已废弃:请使用 where_eq / where_gt 等参数化方法替代。
Sourcepub fn or_where(self, condition: impl Into<String>) -> Self
👎Deprecated since 1.3.0: P0-2: 字符串拼接存在 SQL 注入风险,请使用 or_where_eq/or_where_ne/or_where_gt 等参数化方法
pub fn or_where(self, condition: impl Into<String>) -> Self
P0-2: 字符串拼接存在 SQL 注入风险,请使用 or_where_eq/or_where_ne/or_where_gt 等参数化方法
WHERE 条件(OR)— 字符串拼接,存在 SQL 注入风险
⚠️ 已废弃:请使用 or_where_eq / or_where_gt 等参数化方法替代。
Sourcepub fn where_eq(self, field: impl Into<String>, value: Value) -> Self
pub fn where_eq(self, field: impl Into<String>, value: Value) -> Self
P0-2:参数化等值条件 field = ?(AND 关系)
Sourcepub fn where_ne(self, field: impl Into<String>, value: Value) -> Self
pub fn where_ne(self, field: impl Into<String>, value: Value) -> Self
P0-2:参数化不等条件 field != ?(AND 关系)
Sourcepub fn where_gt(self, field: impl Into<String>, value: Value) -> Self
pub fn where_gt(self, field: impl Into<String>, value: Value) -> Self
P0-2:参数化大于条件 field > ?(AND 关系)
Sourcepub fn where_ge(self, field: impl Into<String>, value: Value) -> Self
pub fn where_ge(self, field: impl Into<String>, value: Value) -> Self
P0-2:参数化大于等于条件 field >= ?(AND 关系)
Sourcepub fn where_lt(self, field: impl Into<String>, value: Value) -> Self
pub fn where_lt(self, field: impl Into<String>, value: Value) -> Self
P0-2:参数化小于条件 field < ?(AND 关系)
Sourcepub fn where_le(self, field: impl Into<String>, value: Value) -> Self
pub fn where_le(self, field: impl Into<String>, value: Value) -> Self
P0-2:参数化小于等于条件 field <= ?(AND 关系)
Sourcepub fn where_like(self, field: impl Into<String>, pattern: Value) -> Self
pub fn where_like(self, field: impl Into<String>, pattern: Value) -> Self
P0-2:参数化 LIKE 条件 field LIKE ?(AND 关系)
Sourcepub fn or_where_eq(self, field: impl Into<String>, value: Value) -> Self
pub fn or_where_eq(self, field: impl Into<String>, value: Value) -> Self
P0-2:参数化 OR 等值条件 OR field = ?
Sourcepub fn or_where_ne(self, field: impl Into<String>, value: Value) -> Self
pub fn or_where_ne(self, field: impl Into<String>, value: Value) -> Self
P0-2:参数化 OR 不等条件 OR field != ?
Sourcepub fn or_where_gt(self, field: impl Into<String>, value: Value) -> Self
pub fn or_where_gt(self, field: impl Into<String>, value: Value) -> Self
P0-2:参数化 OR 大于条件 OR field > ?
Sourcepub fn or_where_ge(self, field: impl Into<String>, value: Value) -> Self
pub fn or_where_ge(self, field: impl Into<String>, value: Value) -> Self
P0-2:参数化 OR 大于等于条件 OR field >= ?
Sourcepub fn or_where_lt(self, field: impl Into<String>, value: Value) -> Self
pub fn or_where_lt(self, field: impl Into<String>, value: Value) -> Self
P0-2:参数化 OR 小于条件 OR field < ?
Sourcepub fn or_where_le(self, field: impl Into<String>, value: Value) -> Self
pub fn or_where_le(self, field: impl Into<String>, value: Value) -> Self
P0-2:参数化 OR 小于等于条件 OR field <= ?
Sourcepub fn or_where_like(self, field: impl Into<String>, pattern: Value) -> Self
pub fn or_where_like(self, field: impl Into<String>, pattern: Value) -> Self
P0-2:参数化 OR LIKE 条件 OR field LIKE ?
Sourcepub fn where_between(
self,
field: impl Into<String>,
start: Value,
end: Value,
) -> Self
pub fn where_between( self, field: impl Into<String>, start: Value, end: Value, ) -> Self
WHERE BETWEEN
Sourcepub fn where_null(self, field: impl Into<String>) -> Self
pub fn where_null(self, field: impl Into<String>) -> Self
WHERE IS NULL
Sourcepub fn where_not_null(self, field: impl Into<String>) -> Self
pub fn where_not_null(self, field: impl Into<String>) -> Self
WHERE IS NOT NULL
Sourcepub fn order_desc(self, field: impl Into<String>) -> Self
pub fn order_desc(self, field: impl Into<String>) -> Self
ORDER BY field DESC
Sourcepub fn join_inner(
self,
table: impl Into<String>,
on_left: impl Into<String>,
on_right: impl Into<String>,
) -> Self
pub fn join_inner( self, table: impl Into<String>, on_left: impl Into<String>, on_right: impl Into<String>, ) -> Self
INNER JOIN
Sourcepub fn join_left(
self,
table: impl Into<String>,
on_left: impl Into<String>,
on_right: impl Into<String>,
) -> Self
pub fn join_left( self, table: impl Into<String>, on_left: impl Into<String>, on_right: impl Into<String>, ) -> Self
LEFT JOIN
Sourcepub fn join_right(
self,
table: impl Into<String>,
on_left: impl Into<String>,
on_right: impl Into<String>,
) -> Self
pub fn join_right( self, table: impl Into<String>, on_left: impl Into<String>, on_right: impl Into<String>, ) -> Self
RIGHT JOIN
Sourcepub fn build_select(&self) -> String
pub fn build_select(&self) -> String
构建 SELECT SQL
Sourcepub fn build_delete(&self) -> String
pub fn build_delete(&self) -> String
构建 DELETE SQL
Sourcepub fn build_count(&self) -> String
pub fn build_count(&self) -> String
构建 COUNT SQL
Sourcepub fn build_exists(&self) -> String
pub fn build_exists(&self) -> String
构建 EXISTS SQL