123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161 |
- <?php
-
-
- namespace Doctrine\DBAL\Driver\OCI8;
-
-
- class OCI8Connection implements \Doctrine\DBAL\Driver\Connection
- {
- private $_dbh;
-
- private $_executeMode = OCI_COMMIT_ON_SUCCESS;
-
-
-
- public function __construct($username, $password, $db, $charset = null, $sessionMode = OCI_DEFAULT)
- {
- if (!defined('OCI_NO_AUTO_COMMIT')) {
- define('OCI_NO_AUTO_COMMIT', 0);
- }
-
- $this->_dbh = @oci_connect($username, $password, $db, $charset, $sessionMode);
- if (!$this->_dbh) {
- throw OCI8Exception::fromErrorInfo(oci_error());
- }
- }
-
-
-
- public function prepare($prepareString)
- {
- return new OCI8Statement($this->_dbh, $prepareString, $this->_executeMode);
- }
-
-
-
- public function query()
- {
- $args = func_get_args();
- $sql = $args[0];
-
- $stmt = $this->prepare($sql);
- $stmt->execute();
- return $stmt;
- }
-
-
-
- public function quote($input, $type=\PDO::PARAM_STR)
- {
- return is_numeric($input) ? $input : "'$input'";
- }
-
-
-
- public function exec($statement)
- {
- $stmt = $this->prepare($statement);
- $stmt->execute();
- return $stmt->rowCount();
- }
-
- public function lastInsertId($name = null)
- {
-
- }
-
-
-
- public function beginTransaction()
- {
- $this->_executeMode = OCI_NO_AUTO_COMMIT;
- return true;
- }
-
-
-
- public function commit()
- {
- if (!oci_commit($this->_dbh)) {
- throw OCI8Exception::fromErrorInfo($this->errorInfo());
- }
- $this->_executeMode = OCI_COMMIT_ON_SUCCESS;
- return true;
- }
-
-
-
- public function rollBack()
- {
- if (!oci_rollback($this->_dbh)) {
- throw OCI8Exception::fromErrorInfo($this->errorInfo());
- }
- $this->_executeMode = OCI_COMMIT_ON_SUCCESS;
- return true;
- }
-
- public function errorCode()
- {
- $error = oci_error($this->_dbh);
- if ($error !== false) {
- $error = $error['code'];
- }
- return $error;
- }
-
- public function errorInfo()
- {
- return oci_error($this->_dbh);
- }
- }
|