传入实体执行(可添加 修改 删除)事务。 IDbHelper dbHelper = new OracleHelper(ConfigHelper.GetConfigString( BusinessDbConnection )); bool result = true ; try { dbHelper.BeginTransaction(); //主表 TE_AREAManager manager = new TE_AREAManager(
传入实体执行(可添加 修改 删除)事务。
启科网络商城系统由启科网络技术开发团队完全自主开发,使用国内最流行高效的PHP程序语言,并用小巧的MySql作为数据库服务器,并且使用Smarty引擎来分离网站程序与前端设计代码,让建立的网站可以自由制作个性化的页面。 系统使用标签作为数据调用格式,网站前台开发人员只要简单学习系统标签功能和使用方法,将标签设置在制作的HTML模板中进行对网站数据、内容、信息等的调用,即可建设出美观、个性的网站。
0
<code class="csharp plain">IDbHelper
dbHelper = <code class="csharp keyword">new <code class="csharp plain">OracleHelper(ConfigHelper.GetConfigString(<code class="csharp string">"BusinessDbConnection"<code class="csharp plain">));
<code class="csharp spaces">
<code class="csharp keyword">bool <code class="csharp plain">result
= <code class="csharp keyword">true<code class="csharp plain">;
<code class="csharp spaces"> <code class="csharp keyword">try
<code class="csharp spaces"> <code class="csharp plain">{
<code class="csharp spaces"> <code class="csharp plain">dbHelper.BeginTransaction();
<code class="csharp spaces"> <code class="csharp comments">//主表
<code class="csharp spaces"> <code class="csharp plain">TE_AREAManager
manager = <code class="csharp keyword">new <code class="csharp plain">TE_AREAManager(dbHelper,
userInfo);
<code class="csharp spaces"> <code class="csharp plain">TE_AREAEntity
tE_AREAEntity = manager.GetObject(dbHelper.SqlSafe(eatxtAREA_ID));
<code class="csharp spaces"> <code class="csharp plain">manager.Delete(tE_AREAEntity);
<code class="csharp comments">//子表
<code class="csharp spaces"> <code class="csharp plain">TE_AREA_SUBManager
submanager = <code class="csharp keyword">new <code class="csharp plain">TE_AREA_SUBManager(dbHelper,
userInfo);
<code class="csharp spaces"> <code class="csharp plain">TE_AREA_SUBEntity
tE_AREA_SUBEntity = submanager.GetObject(dbHelper.SqlSafe(eatxtAREA_ID));
<code class="csharp spaces"> <code class="csharp plain">submanager.Delete(tE_AREA_SUBEntity);
<code class="csharp comments">//事务提交
<code class="csharp spaces"> <code class="csharp plain">dbHelper.CommitTransaction();
<code class="csharp spaces"> <code class="csharp plain">}
<code class="csharp spaces"> <code class="csharp keyword">catch<code class="csharp plain">(Exception
ex)
<code class="csharp spaces"> <code class="csharp plain">{
<code class="csharp comments">//事务回滚
<code class="csharp spaces"> <code class="csharp plain">dbHelper.RollbackTransaction();
<code class="csharp spaces"> <code class="csharp plain">result=<code class="csharp keyword">false<code class="csharp plain">;
<code class="csharp spaces"> <code class="csharp plain">}
<code class="csharp plain">
<code class="csharp plain"><strong>可以传入sql语句执行事务</strong>
<code class="csharp plain">
<code class="csharp plain">IDbHelper
dbHelper = <code class="csharp keyword">new <code class="csharp plain">OracleHelper(ConfigHelper.GetConfigString(<code class="csharp string">"BusinessDbConnection"<code class="csharp plain">));
<code class="csharp spaces"> <code class="csharp keyword">bool <code class="csharp plain">result
= <code class="csharp keyword">true<code class="csharp plain">;
<code class="csharp spaces"> <code class="csharp keyword">try
<code class="csharp spaces"> <code class="csharp plain">{
<code class="csharp spaces"> <code class="csharp plain">dbHelper.BeginTransaction();
<code class="csharp spaces"> <code class="csharp keyword">string <code class="csharp plain">commandText
= <code class="csharp string">"
DELETE FROM TE_AREA WHERE ID=" <code class="csharp plain">+
dbHelper.SqlSafe(id);
<code class="csharp spaces"> <code class="csharp plain">dbHelper.ExecuteNonQuery(sqlString);
<code class="csharp spaces"> <code class="csharp plain">commandText
= <code class="csharp string">"
DELETE FROM TE_AREA_SUB WHERE ID=" <code class="csharp plain">+
dbHelper.SqlSafe(id);
<code class="csharp spaces"> <code class="csharp plain">dbHelper.ExecuteNonQuery(commandText);
<code class="csharp spaces"> <code class="csharp plain">dbHelper.CommitTransaction();
<code class="csharp spaces"> <code class="csharp plain">}
<code class="csharp spaces"> <code class="csharp keyword">catch<code class="csharp plain">(Exception
ex)
<code class="csharp spaces"> <code class="csharp plain">{
<code class="csharp spaces"> <code class="csharp plain">dbHelper.RollbackTransaction();
<code class="csharp spaces"> <code class="csharp plain">result=<code class="csharp keyword">false<code class="csharp plain">;
<code class="csharp spaces"> <code class="csharp plain">}
<code class="csharp plain"><strong> 还可以同时传入实体,SQL语句</strong>
<code class="csharp plain">
<code class="csharp plain">IDbHelper
dbHelper = <code class="csharp keyword">new <code class="csharp plain">OracleHelper(ConfigHelper.GetConfigString(<code class="csharp string">"BusinessDbConnection"<code class="csharp plain">));
<code class="csharp spaces"> <code class="csharp keyword">bool <code class="csharp plain">result
= <code class="csharp keyword">true<code class="csharp plain">;
<code class="csharp spaces"> <code class="csharp keyword">try
<code class="csharp spaces"> <code class="csharp plain">{
<code class="csharp spaces"> <code class="csharp plain">dbHelper.BeginTransaction();
<code class="csharp plain"> <code class="csharp comments">//主表
<code class="csharp spaces"> <code class="csharp plain">TE_AREAManager
manager = <code class="csharp keyword">new <code class="csharp plain">TE_AREAManager(dbHelper,
userInfo);
<code class="csharp spaces"> <code class="csharp plain">TE_AREAEntity
tE_AREAEntity = manager.GetObject(dbHelper.SqlSafe(eatxtAREA_ID));
<code class="csharp spaces"> <code class="csharp plain">manager.Delete(tE_AREAEntity);
<code class="csharp plain"> <code class="csharp comments">//子表
<code class="csharp spaces"> <code class="csharp plain">TE_AREA_SUBManager
submanager = <code class="csharp keyword">new <code class="csharp plain">TE_AREA_SUBManager(dbHelper,
userInfo);
<code class="csharp spaces"> <code class="csharp plain">TE_AREA_SUBEntity
tE_AREA_SUBEntity = submanager.GetObject(dbHelper.SqlSafe(eatxtAREA_ID));
<code class="csharp spaces"> <code class="csharp plain">submanager.Delete(tE_AREA_SUBEntity);
<code class="csharp plain">
<code class="csharp plain">
<code class="csharp comments">//执行SQL语句
<code class="csharp plain">
<code class="csharp keyword">string <code class="csharp plain">commandText
= <code class="csharp string">"
DELETE FROM JINTIANDA WHERE ID=" <code class="csharp plain">+
dbHelper.SqlSafe(id);
<code class="csharp plain">
dbHelper.ExecuteNonQuery(commandText);
<code class="csharp plain"> <code class="csharp comments">//事务提交
<code class="csharp spaces"> <code class="csharp plain">dbHelper.CommitTransaction();
<code class="csharp spaces"> <code class="csharp plain">}
<code class="csharp spaces"> <code class="csharp keyword">catch<code class="csharp plain">(Exception
ex)
<code class="csharp spaces"> <code class="csharp plain">{
<code class="csharp plain"> <code class="csharp comments">//事务回滚
<code class="csharp spaces"> <code class="csharp plain">dbHelper.RollbackTransaction();
<code class="csharp spaces"> <code class="csharp plain">result=<code class="csharp keyword">false<code class="csharp plain">;
<code class="csharp spaces"> <code class="csharp plain">}
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号