MIOLO20
Carregando...
Procurando...
Nenhuma entrada encontrada
OCI8Connection.php
Ir para a documentação deste ficheiro.
1<?php
2/*
3 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
4 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
5 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
6 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
7 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
8 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
9 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
10 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
11 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
12 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
13 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14 *
15 * This software consists of voluntary contributions made by many individuals
16 * and is licensed under the LGPL. For more information, see
17 * <http://www.doctrine-project.org>.
18 */
19
21
28{
29 private $_dbh;
30
31 private $_executeMode = OCI_COMMIT_ON_SUCCESS;
32
40 public function __construct($username, $password, $db, $charset = null, $sessionMode = OCI_DEFAULT)
41 {
42 if (!defined('OCI_NO_AUTO_COMMIT')) {
43 define('OCI_NO_AUTO_COMMIT', 0);
44 }
45
46 $this->_dbh = @oci_connect($username, $password, $db, $charset, $sessionMode);
47 if (!$this->_dbh) {
48 throw OCI8Exception::fromErrorInfo(oci_error());
49 }
50 }
51
58 public function prepare($prepareString)
59 {
60 return new OCI8Statement($this->_dbh, $prepareString, $this->_executeMode);
61 }
62
67 public function query()
68 {
69 $args = func_get_args();
70 $sql = $args[0];
71 //$fetchMode = $args[1];
72 $stmt = $this->prepare($sql);
73 $stmt->execute();
74 return $stmt;
75 }
76
84 public function quote($input, $type=\PDO::PARAM_STR)
85 {
86 return is_numeric($input) ? $input : "'$input'";
87 }
88
94 public function exec($statement)
95 {
96 $stmt = $this->prepare($statement);
97 $stmt->execute();
98 return $stmt->rowCount();
99 }
100
101 public function lastInsertId($name = null)
102 {
103 //TODO: throw exception or support sequences?
104 }
105
115 public function beginTransaction()
116 {
117 $this->_executeMode = OCI_NO_AUTO_COMMIT;
118 return true;
119 }
120
125 public function commit()
126 {
127 if (!oci_commit($this->_dbh)) {
129 }
130 $this->_executeMode = OCI_COMMIT_ON_SUCCESS;
131 return true;
132 }
133
138 public function rollBack()
139 {
140 if (!oci_rollback($this->_dbh)) {
142 }
143 $this->_executeMode = OCI_COMMIT_ON_SUCCESS;
144 return true;
145 }
146
147 public function errorCode()
148 {
149 $error = oci_error($this->_dbh);
150 if ($error !== false) {
151 $error = $error['code'];
152 }
153 return $error;
154 }
155
156 public function errorInfo()
157 {
158 return oci_error($this->_dbh);
159 }
160}
__construct($username, $password, $db, $charset=null, $sessionMode=OCI_DEFAULT)
quote($input, $type=\PDO::PARAM_STR)
$charset
Definição base.php:7