php事务处理后怎的进行页面跳转
php事务处理后怎样进行页面跳转
我用的是smarty模板,中间需要一个事务处理,同时想数据库插入两条数据,而且必须是成功都成功,失败都失败。
开始我用的是mysql_query('begin');
????????????????? mysql_query($sql);
????????????????? mysql_query($sql);
然后一个if判断,都为true的话commit,否则rollback。最后
????????????????? mysql_query('end');
但是在end之后我要进行一个php页面的跳转,加上end后,end以后的php代码都不执行了,数据添加成功与否页面都不尽兴跳转了。
?
?
?
然后我用set autocommit??? ,把自动提交设置成手动,但是和上边情况一样。。。
?
?
后来我写了一个方法,定义一个全局变量想通过全局变量来判断是否成功,但是这个全局变量的值在方法中确实被改变了,但在方法结束后这个值没有传出来,在外边用var_dump($tranResult),一直都是一个空白的值。。。。。。
?
??? function tranType1($type,$product_name,$pic_name,$name,$diameter,$capacity,$pic){
??? ???? ??? global $tranResult;
??? ???? ???
??? ???? ??? $this->db->query('begin');
??? ???? ??? $main_id = $this->addInfoTable1($type,$product_name,$pic_name);?? //这两个是我写的添加信息的方法,返回的是mysql_insert_id()
??? ???? ??? $addTab2 = $this->addInfoTub($main_id,$name,$diameter,$capacity);
??? ???? ??? if(($main_id !== false) && ($addTab2 !== false) ){
??? ??? ??? ??? $upPic = $this->comm->checkPic($pic);
??? ??? ??? ??? if($upPic){ ???
??? ??? ??? ??? ? $this->db->query('commit');??? ??? ??? ???
??? ??? ??? ??? ? $tranResult = true;
??? ??? ??? ??? ? //var_dump($tranResult);
??? ??? ??? ??? }else{
??? ??? ??? ??? ? $this->db->query('rollback');
??? ??? ??? ??? }
??? ??? ??? }else{
??? ??? ??? ??? ?$this->db->query('rollback');
??? ??? ??? }
??? ??? ???
??? ??? ??? $this->db->query('end');
??? ??? ??? var_dump($tranResult);
??? ?}
?
?
?
?
?
小弟实在想不出解决的方案了,请各位大侠来帮忙解决一下,万分感谢!!!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Many users will choose the Huawei brand when choosing smart watches. Among them, Huawei GT3pro and GT4 are very popular choices. Many users are curious about the difference between Huawei GT3pro and GT4. Let’s introduce the two to you. . What are the differences between Huawei GT3pro and GT4? 1. Appearance GT4: 46mm and 41mm, the material is glass mirror + stainless steel body + high-resolution fiber back shell. GT3pro: 46.6mm and 42.9mm, the material is sapphire glass + titanium body/ceramic body + ceramic back shell 2. Healthy GT4: Using the latest Huawei Truseen5.5+ algorithm, the results will be more accurate. GT3pro: Added ECG electrocardiogram and blood vessel and safety

Why Snipping Tool Not Working on Windows 11 Understanding the root cause of the problem can help find the right solution. Here are the top reasons why the Snipping Tool might not be working properly: Focus Assistant is On: This prevents the Snipping Tool from opening. Corrupted application: If the snipping tool crashes on launch, it might be corrupted. Outdated graphics drivers: Incompatible drivers may interfere with the snipping tool. Interference from other applications: Other running applications may conflict with the Snipping Tool. Certificate has expired: An error during the upgrade process may cause this issu simple solution. These are suitable for most users and do not require any special technical knowledge. 1. Update Windows and Microsoft Store apps

Part 1: Initial Troubleshooting Steps Checking Apple’s System Status: Before delving into complex solutions, let’s start with the basics. The problem may not lie with your device; Apple's servers may be down. Visit Apple's System Status page to see if the AppStore is working properly. If there's a problem, all you can do is wait for Apple to fix it. Check your internet connection: Make sure you have a stable internet connection as the "Unable to connect to AppStore" issue can sometimes be attributed to a poor connection. Try switching between Wi-Fi and mobile data or resetting network settings (General > Reset > Reset Network Settings > Settings). Update your iOS version:

In this article, we will show you how to reorder multiple columns in PowerQuery by dragging and dropping. Often, when importing data from various sources, columns may not be in the desired order. Reordering columns not only allows you to arrange them in a logical order that suits your analysis or reporting needs, it also improves the readability of your data and speeds up tasks such as filtering, sorting, and performing calculations. How to rearrange multiple columns in Excel? There are many ways to rearrange columns in Excel. You can simply select the column header and drag it to the desired location. However, this approach can become cumbersome when dealing with large tables with many columns. To rearrange columns more efficiently, you can use the enhanced query editor. Enhancing the query

ReactQuery database plug-in: Methods to implement data import and export, specific code examples are required. With the widespread application of ReactQuery in front-end development, more and more developers are beginning to use it to manage data. In actual development, we often need to export data to local files or import data from local files into the database. In order to implement these functions more conveniently, you can use the ReactQuery database plug-in. The ReactQuery database plugin provides a series of methods

php提交表单通过后,弹出的对话框怎样在当前页弹出php提交表单通过后,弹出的对话框怎样在当前页弹出而不是在空白页弹出?想实现这样的效果:而不是空白页弹出:------解决方案--------------------如果你的验证用PHP在后端,那么就用Ajax;仅供参考:HTML code

This article will introduce how to use PowerQuery to split data into rows. When exporting data from other systems or sources, it is common to encounter situations where the data is stored in cells combining multiple values. With PowerQuery, we can easily split such data into rows, making the data easier to process and analyze. This can happen if the user doesn't understand Excel's rules and accidentally enters multiple data into a cell, or if the data is not formatted correctly when copying/pasting it from other sources. Processing this data requires additional steps to extract and organize the information for analysis or reporting. How to split data in PowerQuery? PowerQuery transformations can be based on a variety of different factors such as word

Watch4pro and gt each have different features and applicable scenarios. If you focus on comprehensive functions, high performance and stylish appearance, and are willing to bear a higher price, then Watch 4 Pro may be more suitable. If you don’t have high functional requirements and pay more attention to battery life and reasonable price, then the GT series may be more suitable. The final choice should be decided based on personal needs, budget and preferences. It is recommended to carefully consider your own needs before purchasing and refer to the reviews and comparisons of various products to make a more informed choice.
