调用sql
支持版本:Java-2.0:V2.19.9;Java-3.0:V3.1.18;
入参说明
调用sql的入参分两部分,一部分是sql语句,另一部分是sql参数,要使用sql参数,必须要在sql语句里添加占位符,例:
// 这是一个 `sql` 语句,用来查询部门下的人员
this.$sql.select("select * from t_user where ParentID='18f923a7-5a5e-426d-94ae-a55ad1a4b240'");
// 转化成带 `sql` 参数,第一个参数用 `{0}` ,第二个参数用 `{1}` ,以此类推
this.$sql.select("select * from t_user where ParentID='{0}'", '18f923a7-5a5e-426d-94ae-a55ad1a4b240');
调用sql-insert
this.$sql.insert(sqlformat, params);
| 参数 | 类型 | 必填 | 描述 |
|---|---|---|---|
| sqlformat | string | 是 | sql字符串 |
| params | array | 是 | 入参数组 |
样例:
this.$sql.insert("insert into table_name values (value1,value2,value3)");
调用sql-select
this.$sql.select(sqlformat, params...);
支持版本: Java-2.0;Java-3.0;
| 参数 | 类型 | 必填 | 描述 |
|---|---|---|---|
| sqlformat | string | 是 | sql字符串 |
| params | 是 | 参数 |
返回内容:返回一个Promise,返回结果为数组对象
样例:
const name = "xxx";
const code = "xxx";
this.$sql.select("SELECT name,code FROM t_user where name='{0}' or code='{1}'",name,code).then(function (res) {
}).catch(function (error) {
});
调用sql-update
this.$sql.update(sqlformat);
支持版本: Java-2.0;Java-3.0;
| 参数 | 类型 | 必填 | 描述 |
|---|---|---|---|
| sqlformat | string | 是 | sql字符串 |
| params | array | 是 | 入参数组 |
返回内容:返回一个Promise
样例:
const name = "xxx";
const code = "xxx";
this.$sql.update("UPDATE person SET name='{0}' WHERE code='{1}'",name,code)
调用sql-delete
this.$sql.delete(sqlformat);
支持版本: Java-2.0:V2.19.9;Java-3.0:V3.1.18;
输入参数:
| 参数 | 类型 | 必填 | 描述 |
|---|---|---|---|
| sqlformat | string | 是 | sql字符串 |
| params | array | 是 | 入参数组 |
样例:
const name = "xxx";
this.$sql.delete("DELETE FROM person WHERE name='{0}'",name)