db = new OracleOCI($dbName, $params); } /** * Restituisce l'oggetto connessione * * @return Oggetto connessione */ public function GetConnection() { return $this->db->_connection; } } class OracleOCI extends DatabaseOCI { private $_connection; private $_dbName; private $_params; public function __construct($dbName, $params = "") { $this->_dbName = $dbName; $this->_params = $params; } private function _setConnection() { if (!is_array($this->_params)) { $this->_connection = false; } else { try { $pooled = CONNESSIONE_OCI_POOLED; $conn = null; if ($pooled) { $conn = oci_connect($this->_params['DB_USER'], $this->_params['DB_PASS'], "(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = " . $this->_params['ORACLE_HOST'] . ")(PORT = " . $this->_params['ORACLE_PORT'] . ")) " . "(CONNECT_DATA =(SERVICE_NAME = " . $this->_params['ORACLE_SERVICE'] . ") (SERVER = POOLED)))", "AL32UTF8"); } else { $conn = oci_connect($this->_params['DB_USER'], $this->_params['DB_PASS'], "(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = " . $this->_params['ORACLE_HOST'] . ")(PORT = " . $this->_params['ORACLE_PORT'] . ")) " . "(CONNECT_DATA =(SERVICE_NAME = " . $this->_params['ORACLE_SERVICE'] . ")))", "AL32UTF8"); } if (!$conn) { $this->_connection = false; } else { $this->_connection = $conn; } } catch (PDOException $e) { echo "Connection failed: " . $e->getMessage(); } } } public function db_getStatement($sql) { $statement = null; try { if (!$this->_connection) { $this->_setConnection(); } $statement = oci_parse($this->_connection, $sql); } catch (Exception $e) { echo $e->getMessage(); } return $statement; } public function getDbName() { return $this->_dbName; } public function lastInsertId() { try { $statement = oci_parse($this->_connection, $getID); $execute = oci_execute($statement, OCI_NO_AUTO_COMMIT); $row = oci_fetch_array($execute, OCI_ASSOC + OCI_RETURN_NULLS); $lastID = $row['LASTINSERTID']; } catch (PDOException $exc) { echo $exc->getMessage(); } return $lastID; } public function db_checkConnection() { return $this->_connection ? true : false; } public function db_execute($statement) { if ($this->_connection) { $execute = oci_execute($statement, OCI_NO_AUTO_COMMIT); } return $execute; } public function db_fetch_assoc($statement) { $rows = array(); if ($this->_connection) { $execute = oci_execute($statement, OCI_NO_AUTO_COMMIT); if ($execute) { while ($row = oci_fetch_assoc($statement)) { $rows[] = $row; } } } return $rows; } public function db_fetch_array($statement) { $row = array(); if ($this->_connection) { $execute = oci_execute($statement, OCI_NO_AUTO_COMMIT); if ($execute) { $row = oci_fetch_array($statement, OCI_ASSOC + OCI_RETURN_NULLS); } } return $row; } public function db_transactionCommit() { if ($this->_connection) { oci_commit($this->_connection); $this->db_close(); } } public function db_transactionRollback() { if ($this->_connection) { oci_rollback($this->_connection); $this->db_close(); } } public function db_free_statement($statement) { try { oci_free_statement($statement); } catch (Exception $e) { echo $e->getMessage(); } } public function db_close() { if ($this->_connection) { try { oci_close($this->_connection); $this->_connection = false; } catch (Exception $e) { echo $e->getMessage(); } } } } if (!isset($conOCI)) { $connessioneOCI = new DatabaseOCI(DBMS, DB_SERVER, array('DB_USER' => DB_USER, 'DB_PASS' => DB_PASS, 'ORACLE_HOST' => ORACLE_HOST, 'ORACLE_PORT' => ORACLE_PORT, 'ORACLE_SERVICE' => ORACLE_SERVICE)); $conOCI = $connessioneOCI->db; } if (!isset($conSpidOCI)) { $connessioneSpidOCI = new DatabaseOCI(DBMS, DB_SERVER, array('DB_USER' => DB_USER_SPID, 'DB_PASS' => DB_PASS_SPID, 'ORACLE_HOST' => ORACLE_HOST, 'ORACLE_PORT' => ORACLE_PORT, 'ORACLE_SERVICE' => ORACLE_SERVICE)); $conSpidOCI = $connessioneSpidOCI->db; }