File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -131,6 +131,8 @@ private function simulateQuery(string $queryString)
131131 return $ this ->cache [$ queryString ] = null ;
132132 }
133133
134+ $ this ->db ->begin_transaction (\MYSQLI_TRANS_START_READ_ONLY );
135+
134136 try {
135137 $ result = $ this ->db ->query ($ simulatedQuery );
136138
@@ -144,6 +146,8 @@ private function simulateQuery(string $queryString)
144146 return $ this ->cache [$ queryString ] = $ resultInfo ;
145147 } catch (mysqli_sql_exception $ e ) {
146148 return $ this ->cache [$ queryString ] = $ e ;
149+ } finally {
150+ $ this ->db ->rollback ();
147151 }
148152 }
149153}
Original file line number Diff line number Diff line change @@ -139,10 +139,22 @@ private function simulateQuery(string $queryString)
139139 return $ this ->cache [$ queryString ] = null ;
140140 }
141141
142+ try {
143+ $ this ->pdo ->beginTransaction ();
144+ } catch (PDOException $ e ) {
145+ // not all drivers may support transactions
146+ }
147+
142148 try {
143149 $ stmt = $ this ->pdo ->query ($ simulatedQuery );
144150 } catch (PDOException $ e ) {
145151 return $ this ->cache [$ queryString ] = $ e ;
152+ } finally {
153+ try {
154+ $ this ->pdo ->rollBack ();
155+ } catch (PDOException $ e ) {
156+ // not all drivers may support transactions
157+ }
146158 }
147159
148160 $ this ->cache [$ queryString ] = [];
You can’t perform that action at this time.
0 commit comments