public function initialize(DataSourceHandler $handler, DataSourceMetaData $datasource) { if (!isset($datasource->database)) { throw new IllegalStateException(t('Entry name from tnsnames.ora is not provided')); } $connection = OCIImplHelper::oci_connect($datasource->username, $datasource->password, $datasource->database); $sql = array('ALTER SESSION SET NLS_SORT=ASCII7_AI', 'ALTER SESSION SET NLS_COMP=LINGUISTIC'); $statementExecutor = new OCIExecuteStatementImpl(); $statementExecutor->execute($handler, $connection, $sql); return $connection; }
public function executeIndividualStatement(DataSourceHandler $handler, $connection, $sql) { $statement = OCIImplHelper::oci_parse($connection, $sql); try { OCIImplHelper::oci_execute($connection, $statement, OCI_NO_AUTO_COMMIT); $affectedRecordCount = OCIImplHelper::oci_num_rows($connection, $statement); } catch (Exception $e) { OCIImplHelper::oci_free_statement($connection, $statement); throw $e; } OCIImplHelper::oci_free_statement($connection, $statement); return $affectedRecordCount; }
public function getColumnMetaData($connection, $statement, $columnIndex) { $columnNumber = $columnIndex + 1; $column = new ColumnMetaData(); $column->name = strtolower(OCIImplHelper::oci_field_name($connection, $statement, $columnNumber)); // preparing the column type $column->type->databaseType = OCIImplHelper::oci_field_type($connection, $statement, $columnNumber); switch ($column->type->databaseType) { case 'VARCHAR2': $column->type->length = OCIImplHelper::oci_field_size($connection, $statement, $columnNumber); break; case 'NUMBER': $column->type->precision = OCIImplHelper::oci_field_precision($connection, $statement, $columnNumber); $column->type->scale = OCIImplHelper::oci_field_scale($connection, $statement, $columnNumber); break; } return $column; }
public function initialize(DataSourceHandler $handler, DataSourceMetaData $datasource) { if (!isset($datasource->database)) { throw new IllegalStateException(t('Entry name from tnsnames.ora is not provided')); } $connection = OCIImplHelper::oci_connect($datasource->username, $datasource->password, $datasource->database); $oracleDateTimeFormat = $handler->getExtension('formatDateValue')->prepareFormat(DateTimeDataTypeHandler::$FORMAT_DEFAULT, FALSE); $oracleDateTimeTZFormat = $handler->getExtension('formatDateValue')->prepareFormat(DateTimeDataTypeHandler::$FORMAT_DEFAULT, TRUE); $sql = array( 'ALTER SESSION SET NLS_SORT=ASCII7_AI', 'ALTER SESSION SET NLS_COMP=LINGUISTIC', "ALTER SESSION SET NLS_DATE_FORMAT='$oracleDateTimeFormat'", "ALTER SESSION SET NLS_TIMESTAMP_FORMAT='$oracleDateTimeFormat'", "ALTER SESSION SET NLS_TIMESTAMP_TZ_FORMAT='$oracleDateTimeTZFormat'"); $statementExecutor = new OCIExecuteStatementImpl(); $statementExecutor->execute($handler, $connection, $sql); return $connection; }