/** * Constructor. * * Receive a database adapter and try to allocate a new OCI cursor. * * @param Zend_Db_Adapter_Oracle $db * @throws Zend_Db_Cursor_Exception */ public function __construct(Zend_Db_Adapter_Oracle $db) { // Get the OCI connection resource and a cursor $conn = $db->getConnection(); $cursor = oci_new_cursor($conn); // Check if the cursor is a valid resource if (!is_resource($cursor)) { require_once 'Zend/Db/Cursor/Exception.php'; throw new Zend_Db_Cursor_Exception('Can\'t allocate a cursor.'); } // Setup $_cursor property $this->_cursor = $cursor; }
public function testAdapterExceptionInvalidLoginCredentials() { $params = $this->_util->getParams(); $params['password'] = '******'; // invalid password try { $db = new Zend_Db_Adapter_Oracle($params); $db->getConnection(); // force connection $this->fail('Expected to catch Zend_Db_Adapter_Oracle_Exception'); } catch (Zend_Exception $e) { $this->assertType('Zend_Db_Adapter_Oracle_Exception', $e, 'Expected to catch Zend_Db_Adapter_Oracle_Exception, got ' . get_class($e)); } }
/** * Check for config options that are mandatory. * Throw exceptions if any are missing. * * @param array $config array of config options * @throws Zend_Db_Adapter_Exception * @return void */ protected function _checkRequiredOptions(array $config) { if (!array_key_exists('host', $config)) { require_once 'Zend/Db/Adapter/Oracle/Exception.php'; throw new Zend_Db_Adapter_Oracle_Exception("Configuration array must have a key for 'host' naming the hostname or ip of the database server"); } parent::_checkRequiredOptions($config); }
/** * */ protected function _connect() { $connected = $this->isConnected(); /** * Está negado o IF abaixo, pois o comando deve ser executado * apenas na primeira conexão para não dar lupe infinito */ if (!$connected) { parent::_connect(); $stmt = $this->prepare("ALTER SESSION SET NLS_DATE_FORMAT = 'YYYY-MM-DD HH24:MI:SS'"); $stmt->execute(); $stmt = $this->prepare("ALTER SESSION SET NLS_NUMERIC_CHARACTERS = '.,'"); $stmt->execute(); try { @($uri = ZendT_Url::getUriApp()); @($obj = Zend_Auth::getInstance()->getStorage()->read()); if (method_exists($obj, 'getLogin')) { $user = Zend_Auth::getInstance()->getStorage()->read()->getLogin(); } else { $user = '******'; } $sql = "BEGIN "; $sql .= " dbms_application_info.set_module('{$uri}', '{$user}'); "; $sql .= "END; "; $stmt = $this->prepare($sql); $stmt->execute(); } catch (Exception $ex) { } } }