1
1
<?php
2
2
namespace Vimeo \MysqlEngine ;
3
3
4
+ use PDO ;
5
+
4
6
class FakePdo extends \PDO
5
7
{
6
8
/**
@@ -70,9 +72,10 @@ public function getServer() : Server
70
72
return $ this ->server ;
71
73
}
72
74
73
- /**
74
- * @param string $statement
75
- */
75
+ /**
76
+ * @param string $statement
77
+ * @return Php7\FakePdoStatement|Php8\FakePdoStatement
78
+ */
76
79
public function prepare ($ statement , $ options = null )
77
80
{
78
81
if (\PHP_MAJOR_VERSION === 8 ) {
@@ -97,20 +100,59 @@ public function lastInsertId($seqname = null) : string
97
100
return $ this ->lastInsertId ;
98
101
}
99
102
103
+ /**
104
+ * @return bool
105
+ */
100
106
public function beginTransaction ()
101
107
{
102
108
Server::snapshot ('transaction ' );
103
109
return true ;
104
110
}
105
111
112
+ /**
113
+ * @return bool
114
+ */
106
115
public function commit ()
107
116
{
108
117
return Server::deleteSnapshot ('transaction ' );
109
118
}
110
119
120
+ /**
121
+ * @return bool
122
+ * @throws Processor\ProcessorException
123
+ */
111
124
public function rollback ()
112
125
{
113
126
Server::restoreSnapshot ('transaction ' );
114
127
return true ;
115
128
}
129
+
130
+ /**
131
+ * @param string $statement
132
+ * @return bool
133
+ */
134
+ public function exec ($ statement )
135
+ {
136
+ $ statement = trim ($ statement );
137
+ if (strpos ($ statement , 'SET ' )===0 ){
138
+ return false ;
139
+ }
140
+
141
+ $ sth = $ this ->prepare ($ statement );
142
+ return $ sth ->execute ();
143
+ }
144
+
145
+ /**
146
+ * @param string $statement
147
+ * @param int $mode
148
+ * @param null $arg3
149
+ * @param array $ctorargs
150
+ * @return Php7\FakePdoStatement|Php8\FakePdoStatement
151
+ */
152
+ public function query ($ statement , $ mode = PDO ::ATTR_DEFAULT_FETCH_MODE , $ arg3 = null , array $ ctorargs = [])
153
+ {
154
+ $ sth = $ this ->prepare ($ statement );
155
+ $ sth ->execute ();
156
+ return $ sth ;
157
+ }
116
158
}
0 commit comments