DBOF_DEBUGOFF
DBOF_DEBUGOFF
DEBUG: No Debug Info.
OCI8 class.
Connect(string $user = NULL, string $pass = NULL, string $host = NULL, integer $exit_on_error = 1, string $use_charset = '', integer $session_mode = -1) : mixed
Performs the connection to Oracle.
If anything goes wrong calls Print_Error(). Also an Oracle procedure is called to register the Application name as defined in dbdefs.inc.php, This helps DBAs to better fine tune their databases according to application needs.
| string | $user | Username used to connect to DB |
| string | $pass | Password to use for given username |
| string | $host | Hostname of database to connect to |
| integer | $exit_on_error | If set to 1 Class will automatically exit with error code, else return error array |
| string | $use_charset | Optional character set to use. |
| integer | $session_mode | Optional the session mode (OCI_SYSOPER/OCI_SYSDBA). |
Either the DB connection handle or an error array/exit, depending how $exit_on_error is set
SetPConnect(boolean $conntype) : boolean
Sets connection behavour.
If FALSE class uses oci_logon to connect. If TRUE class uses oci_plogon to connect (Persistant connection)
| boolean | $conntype | TRUE => Enable persistant connections, FALSE => Disable persistant connections |
The previous state
SetConnectionHandle(resource $extsock)
Allows to set internal socket to external value.
Note that the internal socket descriptor is only overriden if the class has no active connection stored! If already a connection was performed the class does not override it's internal handle to avoid problems!
| resource | $extsock | The connection handle as returned from oci_login(). |
SetModuleAction(string $module, string $action = "", boolean $returnURL = FALSE) : string
Registers the name either throught DBMS_APPLICATION_INFO package or by calling the new PHP 5.3.2+ functions.
| string | $module | The module name to use, Connect() passes the Application name here (max. 48 characters). |
| string | $action | Optional action info to use (max. 32 characters). |
| boolean | $returnURL | If FALSE (default) and no PHP 5.3.2 is in use, calls "DBMS_APPLICATION_INFO()" directly, else returns the call to it. |
If PHP532 is used nothing is returned, else the ready-to-use PL/SQL call to DBMS_APPLICATION_INFO.SET_MODULE().
SetAction(string $action) : boolean
Sets a given string as action (max. 32 bytes) to the current Oracle connection.
Note that this works only for PHP 5.3.2+ and OCI8 must be linked against Oracle 10g or newer, else returns TRUE without doing anything.
| string | $action | Action info to use (max. 32 characters). |
TRUE on success, else FALSE.
SetClientInfo(string $cinfo) : boolean
Sets a given string as client identifier (max. 64 bytes) to the current Oracle connection.
Note that this works only for PHP 5.3.2+ and OCI8 must be linked against Oracle 10g or newer, else returns TRUE without doing anything.
| string | $cinfo | Client info to use (max. 64 bytes). |
TRUE on success, else FALSE.
Query(string $querystring, integer $resflag = OCI_ASSOC, integer $no_exit) : array|integer
Performs a single row query without Bindvar support.
Resflag can be OCI_NUM or OCI_ASSOC depending on what kind of array you want to be returned. WARNING!!!! All previous class versions up to 0.78 had support for Bind vars on this method! This is no longer supported and if you pass more than 3 parameters to this method a warning is generated and execution is halted. Please use ONLY (!) QueryHash() if you want to use bind variables.
| string | $querystring | The query to be executed against the RDBMS |
| integer | $resflag | OCI_NUM for numeric array or OCI_ASSOC (default) for associative array result |
| integer | $no_exit | 1 => Function returns errorcode instead of calling Print_Error() or 0 => Will always call Print_Error() |
The result of the query as either associative or numeric array. In case of an error can be also an assoc. array of error informations.
QueryHash(string $querystring, integer $resflag = OCI_ASSOC, integer $no_exit, $bindvarhash = null) : array|integer
Performs a single row query with Bindvar support passed as associative hash.
Resflag can be OCI_NUM or OCI_ASSOC depending on what kind of array you want to be returned. Remember to pass all required variables for all defined bind vars after the $no_exit parameter as an assoc. array (Key = name of bindvar without ':', value = value to add).
| string | $querystring | The query to be executed against the RDBMS |
| integer | $resflag | OCI_NUM for numeric array or OCI_ASSOC (default) for associative array result |
| integer | $no_exit | 1 => Function returns errorcode instead of calling Print_Error() or 0 => Will always call Print_Error() |
| $bindvarhash |
The result of the query as either associative or numeric array. In case of an error can be also an assoc. array of error informations.
QueryResult(string $querystring) : mixed
Performs a multirow-query and returns result handle.
Required if you want to fetch many data rows. Does not return in case of error, so no further checking is required. NOTE: Bind Var support is deprecated and no longer supported, use QueryResultHash() instead!
| string | $querystring | SQL-Statement to be executed |
Returns the statement handle or an error array in case of an error.
QueryResultHash(string $query, $inhash) : mixed
Executes a query with parameters passed as hash values.
Also IN/OUT and RETURNING INTO <...> clauses are supported. You have to use FetchResult()/FreeResult() after using this function.
| string | $query | The Query to be executed. |
| $inhash |
Either the statement handle or an error code / calling Print_Error().
FetchResult(integer $resflag = OCI_ASSOC, mixed $extstmt = -1) : array
Fetches next datarow.
Returns either numeric (OCI_NUM) or associative (OCI_ASSOC) array for one data row as pointed to by either internal or passed result var.
| integer | $resflag | OCI_ASSOC => Return associative array or OCI_NUM => Return numeric array. |
| mixed | $extstmt | If != -1 then we try to fetch from that passed handle, else the class uses internal saved handle. Useful if you want to perform a lot of different queries. |
The fetched datarow or NULL if no more data exist.
FreeResult(mixed $extstmt = -1) : mixed
Frees result obtained by QueryResult().
You may optionally pass external Result handle, if you omit this parameter the internal handle is freed. This function also checks the built-in statement cache for the handle and removes it from cache, too.
| mixed | $extstmt | Optional your external saved handle to be freed. |
The result of oci_free_statement() is returned.
SetDebug(integer $state)
Function allows debugging of SQL Queries.
$state can have these values:
| integer | $state | The DEBUG level to set |
SQLDebug(boolean $state)
Allows to en- or disable the SQL_TRACE feature of Oracle.
Pass TRUE to enable or FALSE to disable. When enabled all Statements of your
session are saved in a tracefile stored in
$ORACLE_BASE/admin/
| boolean | $state | TRUE to enable or FALSE to disable the SQL_TRACE feature. |
GetErrorText( $exterr = "") : string
This method tries to get the description for a given error message.
Simply pass the $err['message'] field to this function, it tries to extract the required informations and call $ORACLE_HOME/bin/oerr to get the error description. If either the exterr or the internal sqlerrmsg variables are empty this function returns: "No error found."
| $exterr |
The extracted error text.
SetErrorHandling(integer $val) : integer
Allows to set the handling of errors.
| integer | $val | The Error Handling mode you wish to use. |
Returns the old value.
GetConnectRetries() : integer
Returns the number of retries in case of connection problems.
This value can be set globally inside the dbdefs.inc.php file via the OCIDB_CONNECT_RETRIES define but may be changed run-time also via the "setConnectRetries()" method.
The retry counter value currently set.
SetConnectRetries(integer $retcnt) : integer
Change the number of retries the class performs in case of connection problems.
This value is globally setable in the dbdefs.inc.php script (see define OCIDB_CONNECT_RETRIES) but can be set also run-time via this method.
| integer | $retcnt | The new number of connect retries. |
The previous value
SetPrefetch(integer $rows, mixed $extstmt = -1) : boolean
Allows to set the prefetch value when returning results.
Default is 1 which may lead to performance problems when data is transmitted via WAN.
| integer | $rows | Amount of rows to be used for prefetching. |
| mixed | $extstmt | Optionally your own statement handle. If you omit this parameter the internal statement handle is used. |
Return value of OCISetPrefetch()
Print_Error(string $ustr = '', mixed $var2dump = NULL, integer $exit_on_error = 1) : integer|null
Prints out an Oracle error.
Tries to highlight the buggy SQL part of the query and dumps out as much informations as possible. This may lead however to security problems, in this case you can set DBOF_SHOW_NO_ERRORS and the Error informations are returned to the callee instead of being displayed on-screen. An e-mail can be send if configured, for details see dbdefs.inc.php
| string | $ustr | Optional user-error string to be displayed |
| mixed | $var2dump | Optional a variable to be dumped out via print_r() |
| integer | $exit_on_error | If set to default of 1 this function terminates execution of the script by calling exit, else it simply returns. |
If self::DBOF_RETURN_ALL_ERRORS is set returns error code, else exit()s.
SetOutputHash( $outputhash)
Use this function to pass output hash data to QueryHash() function.
This is only required if you are using RETURNING INTO clauses or OUT variables, if you only use the bind variables for input (IN) you do not need to set this. WARNING: You are responsible to clear the array by using clearOutputHash()!
| $outputhash |
Prepare(string $querystring, integer $no_exit) : mixed
Preparses a query but do not execute it (yet).
This allows to use a compiled query inside loops without having to parse it everytime. All prepared() queries will be put into our own QueryCache() so we can use the Prepare()/Execute()/ExecuteHash() pair for more than one query at once.
| string | $querystring | The Query you want to prepare (can contain bind variables). |
| integer | $no_exit | 1 => Function returns errorcode instead of calling Print_Error() or 0 => Will always call Print_Error() |
Either the statement handle on success or an error code / calling print_error().
Execute(mixed $stmt, integer $no_exit) : mixed
Executes a prepare()d statement and returns the result.
You may then Fetch rows with FetchResult() or call FreeResult() to free your allocated result. Execute() searches first our QueryCache before executing, this way we can use almost unlimited Queries at once in the Prepare/Execute pair.
| mixed | $stmt | The statement handle to be executed. |
| integer | $no_exit | 1 => Function returns errorcode instead of calling Print_Error() or 0 => Will always call Print_Error() |
Returns result set read for FetchResult() usage or an error state depending on class setting in case of an error.
ExecuteHash(mixed $stmt, $bindvarhash, integer $no_exit) : mixed
Executes a prepare()d statement and returns the result.
You may then fetch rows with FetchResult() or call FreeResult() to free your allocated result. This method is almost identical to "Execute()" with the addition that bind variables are supported via an associative array.
| mixed | $stmt | The statement handle to be executed. |
| $bindvarhash | ||
| integer | $no_exit | 1 => Function returns errorcode instead of calling Print_Error() or 0 => Will always call Print_Error() |
Returns result set read for FetchResult() usage or an error state depending on class setting in case of an error.
SaveBLOB(string $file_to_save, string $blob_table, string $blob_field, string $where_clause, array $bind_vars = null) : integer
Allows to save a file to a binary object field (BLOB).
Does not commit!
| string | $file_to_save | Full path and filename of file to save |
| string | $blob_table | Name of Table where the blobfield resides |
| string | $blob_field | Name of BLOB field |
| string | $where_clause | Criteria to get the right row (i.e. WHERE ROWID=ABCDEF12345) |
| array | $bind_vars | If given can contain bind variable definition used in WHERE clause |
If all is okay returns 0 else an oracle error code.
SearchQueryCache(mixed $stmt) : integer
Searches internal query cache for given statement id.
Returns index of found statement id or -1 to indicate an error. This function is considered private and should NOT (!) be called from outside this class!
| mixed | $stmt | The statement handle to search for |
The index number of the found statement or -1 if no handle could be found.