Commit 00eee11 1 parent c51130a commit 00eee11 Copy full SHA for 00eee11
File tree 2 files changed +33
-1
lines changed
2 files changed +33
-1
lines changed Original file line number Diff line number Diff line change @@ -106,12 +106,13 @@ public function execute(array $params = [])
106
106
public function receive ()
107
107
{
108
108
$ result = $ this ->connection ->recv ();
109
+ $ this ->recv = true ;
110
+
109
111
if ($ result === false ) {
110
112
throw new MysqlException ('Mysql recv error,connectError= ' . $ this ->connection ->connect_error . ' error= ' . $ this ->connection ->error );
111
113
}
112
114
$ this ->connection ->setDefer (false );
113
115
114
- $ this ->recv = true ;
115
116
$ this ->result = $ result ;
116
117
117
118
return $ result ;
Original file line number Diff line number Diff line change @@ -142,4 +142,35 @@ public function testUpdateByCo($id)
142
142
$ this ->testUpdate ($ id );
143
143
});
144
144
}
145
+
146
+ public function testErrorSql ()
147
+ {
148
+ Db::beginTransaction ();
149
+
150
+ try {
151
+ $ user = new User ();
152
+ $ user ->setName ('limx ' );
153
+ $ user ->setSex (1 );
154
+ $ user ->setAge (27 );
155
+ $ user ->setDesc ('Swoft ' );
156
+ $ id = $ user ->save ()->getResult ();
157
+
158
+ $ sql = 'SELECT des FROM `user` WHERE id = ? ' ;
159
+ $ res = Db::query ($ sql , [$ id ])->getResult ();
160
+ $ this ->assertTrue (false );
161
+ Db::commit ();
162
+ } catch (\Exception $ ex ) {
163
+ Db::rollback ();
164
+
165
+ $ user = User::findById ($ id )->getResult ();
166
+ $ this ->assertNull ($ user );
167
+ }
168
+ }
169
+
170
+ public function testErrorSqlByCo ()
171
+ {
172
+ go (function () {
173
+ $ this ->testErrorSql ();
174
+ });
175
+ }
145
176
}
You can’t perform that action at this time.
0 commit comments