/** * Executes given SQL statement. This is an overloaded method. * * @param string $sql SQL statement * @return resource Result resource identifier or null * @access protected */ function _execute($sql) { $this->_statementId = @ociparse($this->connection, $sql); if (!$this->_statementId) { $this->_setError($this->connection); return false; } if ($this->__transactionStarted) { $mode = OCI_DEFAULT; } else { $mode = OCI_COMMIT_ON_SUCCESS; } if (!@ociexecute($this->_statementId, $mode)) { $this->_setError($this->_statementId); return false; } $this->_setError(null, true); switch (ocistatementtype($this->_statementId)) { case 'DESCRIBE': case 'SELECT': $this->_scrapeSQL($sql); break; default: return $this->_statementId; break; } if ($this->_limit >= 1) { ocisetprefetch($this->_statementId, $this->_limit); } else { ocisetprefetch($this->_statementId, 3000); } $this->_numRows = ocifetchstatement($this->_statementId, $this->_results, $this->_offset, $this->_limit, OCI_NUM | OCI_FETCHSTATEMENT_BY_ROW); $this->_currentRow = 0; $this->limit(); return $this->_statementId; }
/** * Execute the query * * @access private called by the base class * @param string an SQL query * @return resource */ function _execute($sql) { // oracle must parse the query before it is run. All of the actions with // the query are based on the statement id returned by ociparse $this->_set_stmt_id($sql); ocisetprefetch($this->stmt_id, 1000); return @ociexecute($this->stmt_id, $this->_commit); }
/** * Execute the query * * @access private called by the base class * @param string an SQL query * @return resource */ function execute($sql) { // oracle must parse the query before it // is run, all of the actions with // the query are based off the statement id // returned by ociparse $this->_set_stmt_id($sql); ocisetprefetch($this->stmt_id, 1000); return @ociexecute($this->stmt_id); }
/** * Executes a DB statement prepared with prepare(). * * To determine how many rows of a result set get buffered using * ocisetprefetch(), see the "result_buffering" option in setOptions(). * This option was added in Release 1.7.0. * * @param resource $stmt a DB statement resource returned from prepare() * @param mixed $data array, string or numeric data to be used in * execution of the statement. Quantity of items * passed must match quantity of placeholders in * query: meaning 1 for non-array items or the * quantity of elements in the array. * * @return mixed returns an oic8 result resource for successful SELECT * queries, DB_OK for other successful queries. * A DB error object is returned on failure. * * @see DB_oci8::prepare() */ function &execute($stmt, $data = array()) { $data = (array) $data; $this->last_parameters = $data; $this->last_query = $this->_prepared_queries[(int) $stmt]; $this->_data = $data; $types = $this->prepare_types[(int) $stmt]; if (count($types) != count($data)) { $tmp = $this->raiseError(DB_ERROR_MISMATCH); return $tmp; } $i = 0; foreach ($data as $key => $value) { if ($types[$i] == DB_PARAM_MISC) { /* * Oracle doesn't seem to have the ability to pass a * parameter along unchanged, so strip off quotes from start * and end, plus turn two single quotes to one single quote, * in order to avoid the quotes getting escaped by * Oracle and ending up in the database. */ $data[$key] = preg_replace("/^'(.*)'\$/", "\\1", $data[$key]); $data[$key] = str_replace("''", "'", $data[$key]); } elseif ($types[$i] == DB_PARAM_OPAQUE) { $fp = @fopen($data[$key], 'rb'); if (!$fp) { $tmp = $this->raiseError(DB_ERROR_ACCESS_VIOLATION); return $tmp; } $data[$key] = fread($fp, filesize($data[$key])); fclose($fp); } elseif ($types[$i] == DB_PARAM_SCALAR) { // Floats have to be converted to a locale-neutral // representation. if (is_float($data[$key])) { $data[$key] = $this->quoteFloat($data[$key]); } } if (!@OCIBindByName($stmt, ':bind' . $i, $data[$key], -1)) { $tmp = $this->oci8RaiseError($stmt); return $tmp; } $this->last_query = str_replace(':bind' . $i, $this->quoteSmart($data[$key]), $this->last_query); $i++; } if ($this->autocommit) { $success = @OCIExecute($stmt, OCI_COMMIT_ON_SUCCESS); } else { $success = @OCIExecute($stmt, OCI_DEFAULT); } if (!$success) { $tmp = $this->oci8RaiseError($stmt); return $tmp; } $this->last_stmt = $stmt; if ($this->manip_query[(int) $stmt] || $this->_next_query_manip) { $this->_last_query_manip = true; $this->_next_query_manip = false; $tmp = DB_OK; } else { $this->_last_query_manip = false; @ocisetprefetch($stmt, $this->options['result_buffering']); $tmp = new DB_result($this, $stmt); } return $tmp; }
/** * Execute a query * @param string $query query * @param boolean $is_manip if the query is a manipulation query * @param resource $connection * @param string $database_name * @return result or error object * @access protected */ function &_doQuery($query, $is_manip = false, $connection = null, $database_name = null) { $this->last_query = $query; $result = $this->debug($query, 'query', array('is_manip' => $is_manip, 'when' => 'pre')); if ($result) { if (PEAR::isError($result)) { return $result; } $query = $result; } if ($this->getOption('disable_query')) { if ($is_manip) { return 0; } return null; } if (is_null($connection)) { $connection = $this->getConnection(); if (PEAR::isError($connection)) { return $connection; } } $result = @OCIParse($connection, $query); if (!$result) { $err = $this->raiseError(null, null, null, 'Could not create statement', __FUNCTION__); return $err; } $mode = $this->in_transaction ? OCI_DEFAULT : OCI_COMMIT_ON_SUCCESS; if (!@OCIExecute($result, $mode)) { $err =& $this->raiseError($result, null, null, 'Could not execute statement', __FUNCTION__); return $err; } if (is_numeric($this->options['result_prefetching'])) { @ocisetprefetch($result, $this->options['result_prefetching']); } $this->debug($query, 'query', array('is_manip' => $is_manip, 'when' => 'post', 'result' => $result)); return $result; }
function _stored_execute($sql, $params) { // oracle must parse the query before it is run. All of the actions with // the query are based on the statement id returned by ociparse $this->stmt_id = FALSE; $this->_set_stmt_id($sql); //begin modification if (!$this->stmt_id) { $e = oci_error($this->stmt_id); log_message('error', $e['message']); return FALSE; } if ($this->binds !== FALSE) { //print_r("binding parameters"); $this->_bind_params($params); } ocisetprefetch($this->stmt_id, 1000); $exec_worked = ociexecute($this->stmt_id, $this->_commit); if ($exec_worked === FALSE) { // if ociexecute failed, grab the oracle error message and log it $e = oci_error($this->stmt_id); log_message('error', $e['message']); } return $exec_worked; //@ociexecute($this->stmt_id, $this->_commit); //end modification }
/** * Prepare the query * Only if Oracle Type * * @access protected * @return string * @see self::execute() */ function _prep_query($sQuery) { if (true === $this->_bPrefetch) { @ocisetprefetch($this->stmt_id, $this->_iPrefetch); } if (count($this->aInputBinds) + count($this->aOutputBinds) > 0) { if (is_resource($this->stmt_id)) { // Append Data to collection reset($this->aInputBinds); for ($iBind = 0, $iMaxi = count($this->aInputBinds); $iBind < $iMaxi; $iBind++) { if (false === $this->_setInputBind(current($this->aInputBinds))) { return false; } else { next($this->aInputBinds); } } // Append Data to collection reset($this->aOutputBinds); for ($iBind = 0, $iMaxi = count($this->aOutputBinds); $iBind < $iMaxi; $iBind++) { $aBind = current($this->aOutputBinds); if (false === $this->_setOutputBind($aBind)) { return false; } else { $this->aOutputBinds[key($this->aOutputBinds)] = $aBind; next($this->aOutputBinds); } } } } }
function DBNavStart() { if ($this->bFetched === true) { return; } $this->bFetched = true; $this->NavPageNomer = $this->PAGEN < 1 ? $_SESSION[$this->SESS_PAGEN] < 1 ? 1 : $_SESSION[$this->SESS_PAGEN] : $this->PAGEN; if ($this->NavShowAll) { $NavFirstRecordShow = 0; $NavLastRecordShow = 100000; } else { $NavFirstRecordShow = $this->NavPageSize * ($this->NavPageNomer - 1); $NavLastRecordShow = $this->NavPageSize * $this->NavPageNomer; } $temp_arrray = array(); $num_rows = 0; $rsEnd = false; $cache_arrray = array(); @ocisetprefetch($this->result, 100); while ($num_rows < $NavFirstRecordShow && !$rsEnd) { if (OCIFetchInto($this->result, $db_result_array, OCI_ASSOC + OCI_RETURN_NULLS + OCI_RETURN_LOBS)) { $num_rows++; if (count($cache_arrray) == $NavPageSize) { $cache_arrray = array(); } $cache_arrray[] = $db_result_array; } else { $rsEnd = true; } } if ($rsEnd && count($cache_arrray) > 0) { $this->NavPageNomer = floor($num_rows / $this->NavPageSize); if ($num_rows % $this->NavPageSize > 0) { $this->NavPageNomer++; } $temp_arrray = $cache_arrray; } $bFirst = true; while ($num_rows < $NavLastRecordShow && !$rsEnd) { if (OCIFetchInto($this->result, $db_result_array, OCI_ASSOC + OCI_RETURN_NULLS + OCI_RETURN_LOBS)) { $num_rows++; $temp_arrray[] = $db_result_array; } else { $rsEnd = true; if ($bFirst && count($cache_arrray) > 0) { $this->NavPageNomer = floor($num_rows / $this->NavPageSize); if ($num_rows % $this->NavPageSize > 0) { $this->NavPageNomer++; } $temp_arrray = $cache_arrray; } } $bFirst = false; } if (!$rsEnd) { while (OCIFetch($this->result)) { $num_rows++; } } $this->arResult = $temp_arrray; $this->NavRecordCount = $num_rows; if ($this->NavShowAll) { $this->NavPageSize = $this->NavRecordCount; $this->NavPageNomer = 1; } if ($this->NavPageSize > 0) { $this->NavPageCount = floor($this->NavRecordCount / $this->NavPageSize); } else { $this->NavPageCount = 0; } if ($this->NavRecordCount % $this->NavPageSize > 0) { $this->NavPageCount++; } }
ocidefinebyname(); ocierror(); ociexecute(); ocifetch(); ocifetchinto(); ocifetchstatement(); ocifreecollection(); ocifreecursor(); ocifreedesc(); ocifreestatement(); ociinternaldebug(); ociloadlob(); ocilogoff(); ocilogon(); ocinewcollection(); ocinewcursor(); ocinewdescriptor(); ocinlogon(); ocinumcols(); ociparse(); ociplogon(); ociresult(); ocirollback(); ocirowcount(); ocisavelob(); ocisavelobfile(); ociserverversion(); ocisetprefetch(); ocistatementtype(); ociwritelobtofile(); ociwritetemporarylob();