1 Star 1 Fork 1

c./goframe框架

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
.idea
container
contrib
crypto
database
gdb
testdata
gdb.go
gdb_core.go
gdb_core_config.go
gdb_core_ctx.go
gdb_core_link.go
gdb_core_stats.go
gdb_core_structure.go
gdb_core_trace.go
gdb_core_transaction.go
gdb_core_underlying.go
gdb_core_utility.go
gdb_driver_default.go
gdb_driver_wrapper.go
gdb_driver_wrapper_db.go
gdb_func.go
gdb_model.go
gdb_model_builder.go
gdb_model_builder_where.go
gdb_model_builder_where_prefix.go
gdb_model_builder_whereor.go
gdb_model_builder_whereor_prefix.go
gdb_model_cache.go
gdb_model_delete.go
gdb_model_fields.go
gdb_model_hook.go
gdb_model_insert.go
gdb_model_join.go
gdb_model_lock.go
gdb_model_option.go
gdb_model_order_group.go
gdb_model_select.go
gdb_model_soft_time.go
gdb_model_transaction.go
gdb_model_update.go
gdb_model_utility.go
gdb_model_where.go
gdb_model_where_prefix.go
gdb_model_whereor.go
gdb_model_whereor_prefix.go
gdb_model_with.go
gdb_result.go
gdb_schema.go
gdb_statement.go
gdb_type_record.go
gdb_type_result.go
gdb_type_result_scanlist.go
gdb_z_example_test.go
gdb_z_mysql_internal_test.go
gredis
debug/gdebug
encoding
errors
frame
i18n/gi18n
internal
net
os
test/gtest
text
util
翻译
.gitignore
DirectoryV3.xml
LICENSE
README.MD
_命令 V1.1.bat
go.mod
go.sum
version.go
原版备份@v2.7.1.rar
备注.xls
克隆/下载
gdb_model_delete.go 2.63 KB
一键复制 编辑 原始数据 按行查看 历史
// 版权归GoFrame作者(https://goframe.org)所有。保留所有权利。
//
// 本源代码形式受MIT许可证条款约束。
// 如果未随本文件一同分发MIT许可证副本,
// 您可以在https://github.com/gogf/gf处获取。
// md5:a9832f33b234e3f3
package db类
import (
"database/sql"
gcode "gitee.com/go_888/goframe/errors/gcode"
gerror "gitee.com/go_888/goframe/errors/gerror"
"gitee.com/go_888/goframe/internal/intlog"
gstr "gitee.com/go_888/goframe/text/gstr"
)
// X删除 执行针对模型的 "DELETE FROM ... " 语句。
// 可选参数 `where` 与 Model.Where 函数的参数相同,
// 请参考 Model.Where 查看详细用法。
// md5:efc496574e0829d8
func (m *X结构_Model) X删除(条件 ...interface{}) (结果 sql.Result, 错误 error) {
var ctx = m.X取上下文对象()
if len(条件) > 0 {
return m.X条件(条件[0], 条件[1:]...).X删除()
}
defer func() {
if 错误 == nil {
m.checkAndRemoveSelectCache(ctx)
}
}()
var (
conditionWhere, conditionExtra, conditionArgs = m.formatCondition(ctx, false, false)
conditionStr = conditionWhere + conditionExtra
fieldNameDelete, fieldTypeDelete = m.softTimeMaintainer().GetFieldNameAndTypeForDelete(
ctx, "", m.tablesInit,
)
)
if m.unscoped {
fieldNameDelete = ""
}
if !gstr.X是否包含并忽略大小写(conditionStr, " WHERE ") || (fieldNameDelete != "" && !gstr.X是否包含并忽略大小写(conditionStr, " AND ")) {
intlog.Printf(
ctx,
`SQL 条件字符串 "%s" 中没有 WHERE 子句,无法执行 DELETE 操作,字段名: %s`,
conditionStr, fieldNameDelete,
)
return nil, gerror.X创建错误码(
gcode.X变量_CodeMissingParameter,
"DELETE 操作应该包含 WHERE 条件语句",
)
}
// Soft deleting.
if fieldNameDelete != "" {
dataHolder, dataValue := m.softTimeMaintainer().GetDataByFieldNameAndTypeForDelete(
ctx, "", fieldNameDelete, fieldTypeDelete,
)
in := &X结构_HookUpdateInput{
internalParamHookUpdate: internalParamHookUpdate{
internalParamHook: internalParamHook{
link: m.getLink(true),
},
handler: m.hookHandler.Update,
},
Model: m,
Table: m.tables,
Data: dataHolder,
Condition: conditionStr,
Args: append([]interface{}{dataValue}, conditionArgs...),
}
return in.Next(ctx)
}
in := &X结构_HookDeleteInput{
internalParamHookDelete: internalParamHookDelete{
internalParamHook: internalParamHook{
link: m.getLink(true),
},
handler: m.hookHandler.Delete,
},
Model: m,
Table: m.tables,
Condition: conditionStr,
Args: conditionArgs,
}
return in.Next(ctx)
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/go_888/goframe.git
git@gitee.com:go_888/goframe.git
go_888
goframe
goframe框架
782a3f7170cf

搜索帮助