File tree Expand file tree Collapse file tree 2 files changed +46
-0
lines changed
src/Crate/DBAL/Driver/PDOCrate
test/Crate/Test/DBAL/Functional Expand file tree Collapse file tree 2 files changed +46
-0
lines changed Original file line number Diff line number Diff line change 2323namespace Crate \DBAL \Driver \PDOCrate ;
2424
2525use Crate \PDO \PDOCrateDB ;
26+ use Doctrine \DBAL \Driver \PDO \Exception ;
27+ use Doctrine \DBAL \Driver \PDO \Statement ;
2628use Doctrine \DBAL \Driver \ServerInfoAwareConnection ;
29+ use Doctrine \DBAL \Driver \Statement as StatementInterface ;
2730
2831class PDOConnection extends PDOCrateDB implements ServerInfoAwareConnection
2932{
@@ -49,4 +52,41 @@ public function requiresQueryForServerVersion()
4952 {
5053 return false ;
5154 }
55+
56+ /**
57+ * {@inheritDoc}
58+ *
59+ * References:
60+ * - https://github.com/doctrine/dbal/issues/2025
61+ * - https://github.com/doctrine/dbal/pull/517
62+ * - https://github.com/doctrine/dbal/pull/373
63+ */
64+ public function prepare ($ sql , $ options = null ): StatementInterface
65+ {
66+ try {
67+ $ stmt = $ this ->connection ->prepare ($ sql , $ options );
68+ assert ($ stmt instanceof PDOStatement);
69+
70+ return new Statement ($ stmt );
71+ } catch (PDOException $ exception ) {
72+ throw Exception::new ($ exception );
73+ }
74+ }
75+
76+ /**
77+ * {@inheritDoc}
78+ */
79+ public function exec ($ sql ): int
80+ {
81+ try {
82+ $ result = $ this ->connection ->exec ($ sql );
83+
84+ assert ($ result !== false );
85+
86+ return $ result ;
87+ } catch (PDOException $ exception ) {
88+ throw Exception::new ($ exception );
89+ }
90+ }
91+
5292}
Original file line number Diff line number Diff line change @@ -66,6 +66,12 @@ public function testGetDriver()
6666 $ this ->assertInstanceOf ('Crate\DBAL\Driver\PDOCrate\Driver ' , $ this ->_conn ->getDriver ());
6767 }
6868
69+ /**
70+ * @var \Doctrine\DBAL\Statement $stmt
71+ *
72+ * @return void
73+ * @throws \Doctrine\DBAL\Exception
74+ */
6975 public function testStatement ()
7076 {
7177 $ sql = 'SELECT * FROM sys.cluster ' ;
You can’t perform that action at this time.
0 commit comments