1
+ <?php
2
+ /*
3
+ * $Id$
4
+ *
5
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
6
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
7
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
8
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
9
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
10
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
11
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
12
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
13
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
14
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
15
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
16
+ *
17
+ * This software consists of voluntary contributions made by many individuals
18
+ * and is licensed under the LGPL. For more information, see
19
+ * <http://www.doctrine-project.org>.
20
+ */
21
+
22
+ namespace Doctrine \DBAL \Driver \OCI8 ;
23
+
24
+ /**
25
+ * OCI8 implementation of the Connection interface.
26
+ *
27
+ * @since 2.0
28
+ */
29
+ class OCI8Connection implements \Doctrine \DBAL \Driver \Connection
30
+ {
31
+ private $ _dbh ;
32
+
33
+ public function __construct ($ username , $ password , $ db )
34
+ {
35
+ $ this ->_dbh = oci_connect ($ username , $ password , $ db );
36
+ }
37
+
38
+ public function prepare ($ prepareString )
39
+ {
40
+ return new OCI8Statement ($ this ->_dbh , $ prepareString );
41
+ }
42
+
43
+ public function query ()
44
+ {
45
+ $ args = func_get_args ();
46
+ $ sql = $ args [0 ];
47
+ //$fetchMode = $args[1];
48
+ $ stmt = $ this ->prepare ($ sql );
49
+ $ stmt ->execute ();
50
+ return $ stmt ;
51
+ }
52
+
53
+ public function quote ($ input )
54
+ {
55
+ return is_numeric ($ input ) ? $ input : "' $ input' " ;
56
+ }
57
+
58
+ public function exec ($ statement )
59
+ {
60
+ $ stmt = $ this ->prepare ($ statement );
61
+ $ stmt ->execute ();
62
+ return $ stmt ->rowCount ();
63
+ }
64
+
65
+ public function lastInsertId ($ name = null )
66
+ {
67
+ //TODO: throw exception or support sequences?
68
+ }
69
+
70
+ public function beginTransaction ()
71
+ {
72
+ return true ;
73
+ }
74
+
75
+ public function commit ()
76
+ {
77
+ return oci_commit ($ this ->_dbh );
78
+ }
79
+
80
+ public function rollBack ()
81
+ {
82
+ return oci_rollback ($ this ->_dbh );
83
+ }
84
+
85
+ public function errorCode ()
86
+ {
87
+ $ error = oci_error ($ this ->_dbh );
88
+ if ($ error !== false ) {
89
+ $ error = $ error ['code ' ];
90
+ }
91
+ return $ error ;
92
+ }
93
+
94
+ public function errorInfo ()
95
+ {
96
+ return oci_error ($ this ->_dbh );
97
+ }
98
+
99
+ }
0 commit comments