{"id":20672852,"url":"https://github.com/siegel2k16/db_oci8","last_synced_at":"2025-07-22T08:32:10.576Z","repository":{"id":57056673,"uuid":"144461895","full_name":"SieGeL2k16/db_oci8","owner":"SieGeL2k16","description":"Oracle database class using OCI8 extension","archived":false,"fork":false,"pushed_at":"2018-08-12T11:47:49.000Z","size":784,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-21T11:06:02.743Z","etag":null,"topics":["class","db-oci8","oracle-database","php"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SieGeL2k16.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-08-12T11:41:10.000Z","updated_at":"2018-10-24T07:25:29.000Z","dependencies_parsed_at":"2022-08-24T07:30:22.624Z","dependency_job_id":null,"html_url":"https://github.com/SieGeL2k16/db_oci8","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/SieGeL2k16/db_oci8","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SieGeL2k16%2Fdb_oci8","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SieGeL2k16%2Fdb_oci8/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SieGeL2k16%2Fdb_oci8/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SieGeL2k16%2Fdb_oci8/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SieGeL2k16","download_url":"https://codeload.github.com/SieGeL2k16/db_oci8/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SieGeL2k16%2Fdb_oci8/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266456245,"owners_count":23931383,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["class","db-oci8","oracle-database","php"],"created_at":"2024-11-16T20:39:08.423Z","updated_at":"2025-07-22T08:32:10.538Z","avatar_url":"https://github.com/SieGeL2k16.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"## PHP OCI8 Class written by Sascha 'SieGeL' Pfalz\n\nLast Updated: 12-Aug-2018\n\n###  INTRODUCTION\n\nThis class was mainly created to reduce the code size of complex PHP\napplications that interact with Oracle Databases. Instead of writing down\nalways the same procedures like OCILogin()/OCIParse() etc. the class provides\na much simpler way of using Oracle while still supporting bind vars, BLOBs\nand various other helpful methods.\n\nThis doc lists the various configuration methods and gives a small overview\nhow the class works, what to do in case of an error etc. For examples how\nto use this class please refer to the examples directory, I have supplied\nvarious examples that show how to use the class.\nIn addition you can download the \"Oracle Information Site\" package from\nmy homepage, this little application shows how to use this class in\na real world example.\n\nNote that since the 1.00 release two versions of the class are shipped\nwithin the distribution archive to allow either the usage of the class\nunder PHP 4 or PHP 5. New projects however should always use the PHP 5\nclass, as the PHP 4 is at end-of-life. See also the supplied file\n\"PHP4_PHP5_changes.txt\" for details about the differences between the\ntwo versions of this class.\n\n\n#### FILES PROVIDED IN THIS RELEASE\n\nThe distribution archive contains several directories and files,\nhere's an overview of these files:\n\n- **CHANGELOG.md**          -\u003e Changelog in chronological order\n- **_create_docs.sh**       -\u003e Small bash script to create PHPDocumentor docs\n- **dbdefs.inc.php**        -\u003e Configuration file for the PHP 5 class\n- **db_oci8.class.php**     -\u003e The PHP 5 class\n- **docs/**                 -\u003e PHPDocumentor documentation in HTML format\n- **examples/**             -\u003e Contains various examples for this class\n- **LICENCE**               -\u003e The BSD licence\n- **PHP4/**                 -\u003e Contains PHP 4 class + config file\n- **PHP4_PHP5_changes.txt** -\u003e Readme explains differences between the PHP 4 and the PHP 5 version of the db_oci8 class.\n- **README.md**             -\u003e The file you are currently reading\n\n\n### REQUIREMENTS\n\nThis class require the following components:\n\n- PHP 4/5/7 (last tested on PHP 7.1.1) - Note that the distribution archive\n  now ships PHP 4 AND PHP 5 versions of the class!\n- Oracle 8i, 9i, 10g or 11g (last tested on 11gR2)\n- Optionally the instantclient package (tested with 10g/11g/12g Instantclient)\n\n\n### INSTALLATION AND USAGE\n\n#### Using Composer\n\nJust call the following command to add this class to your project:\n\n`composer require spfalz/db_oci8\n`\n\n#### Manual installation\n\nCopy the supplied class file to a directory of your choice. If you still\nuse PHP 4, use the file \"PHP4/oci8_class.php\", for PHP 5 and newer use the\nfile \"db_oci8.class.php\".\n\nAlso copy the file dbdefs.inc.php to the same directory you have copied\nthe class file.\nThe dbdefs_inc.php file serves as the configuration file for the class.\nYou may give an alternate path to this file in the constructor of this class.\n\nThe following defines can/must be set to use the class inside dbdefs.inc.php:\n\n**OCIDB_USER [required]**\n\n- Oracle Username used as default connection, mandatory.\n\n\n**OCIDB_PASS [required]**\n\n- Oracle Password for useraccount above, mandatory.\n\n\n**OCIDB_HOST [optional]**\n\n- TNS Name of target database. For correct names you may simply\n  try to connect locally to your Oracle DB with SQL*Plus, the name you have\n  used on the SQL*Plus connection string should also work here. If your\n  environment is correctly configured you can leave out this parameter,\n  the ORACLE_SID is then used to connect local to your oracle DB if your\n  PHP runs on the same host as the Database. You can also set TWO_TASK to your TNS name in case you use Instantclient.\n\n\n**OCIAPPNAME [required]**\n\n- Name of your application, mandatory.\n  This is used in error messages and also to register this name to Oracle\n  if you set `DB_REGISTER = 1`\n\n\n**DB_REGISTER [optional]**\n\n- When set to 1 the class automatically calls the PL/SQL package\n  `DBMS_APPLICATION_INFO.SET_MODULE()` to register the name of your application\n  to Oracle (OCIAPPNAME define). This is useful to track Queries and stats\n  inside Oracle. Set to 0 to disable auto register.\n  If you are running PHP 5.3.2 or newer the class won't use anymore the\n  `DBMS_APPLICATION_INFO` methods,instead the new functions\n  `oci_set_module_name()` and `oci_set_action()` are used. See description\n  of the class method `SetModuleAction()` for details.\n\n\n**DB_NUM_DECIMAL / DB_NUM_GROUPING [optional]**\n\n- Both flags are required to handle numeric values in localized environments,\n  i.e. germans are using the '.' as grouping character and the ',' as decimal\n  point, while americans do exactly the opposite. To avoid problems when your\n  application makes use of `setlocale()` and other locale specific things you\n  must enter the appropiate characters for your language to use. The class\n  will then issue an `ALTER SESSION SET NLS_NUMERIC_CHARACTERS = \u003cxY\u003e` after\n  successfully connecting to the database.\n\n\n**DB_ERRORMODE [optional]**\n\n- This flag is used to configure the handling of errors. Whenever an error\n  occure the class automatically shows a box with a lot of informations, i.e.\n  the query used, the position of the first error inside the query, the query\n  counter, filename of PHP script etc, and the error is also reported to the\n  PHP error log with the **OCIAPPNAME** in front of the output.\n  It also may send an email to a given account to inform the developer\n  automatically. Finally the last transaction is rolled back and the script\n  execution is terminated.\n  However it maybe not always feasible to have this automatic error handling\n  active, maybe you want to handle everything on your own or you want to hide\n  internal facts to the customer in productive environments.\n\n  You have currently three choices to set here:\n\n  **\\spfalz\\db_oci8::DBOF_SHOW_NO_ERRORS (0)**\n\n   This hides important informations like the query which produced this error.\n   Only the OCI error code, the PHP scriptname and the error description\n   is shown, everything else is hidden. Useful for productive enviroments.\n   This is also the default setting if not configured.\n\n  **\\spfalz\\db_oci8::DBOF_SHOW_ALL_ERRORS (1)**\n\n    This lists a lot more informations like query etc. Very useful when\n    developing a PHP application, as this should easily show where the error\n    occured. But be warned, the user may see informations he shouldn't\n    normally see (query i.e.), so make sure that you disable this for\n    productive environments!\n\n  **\\spfalz\\db_oci8::DBOF_RETURN_ALL_ERRORS (2)**\n\n    In this mode all errors are returned with their OCI error code, the class\n    does not exit nor abort the program execution, you are on your own to\n    handle the returned error. This is useful to use the class in automatic\n    scripts like some kind of CSV im-/export script.\n\n\n**DB_DEFAULT_PREFETCH [optional]**\n\n- Allows to set how many rows should be prefetched when querying data. PHP's\ndefault value is 1 row, you can set your own value here to override the default\nPHP setting.\n\n\n**OCIDB_ADMINEMAIL [optional]**\n\n- Set here a valid email address where you want to have error reports sent to.\nTo let this work you have to set **OCIDB_SENTMAILONERROR = 1**. Whenever the\nclass encounters an error and automatic error handling is activated, the class\nsends out an email to this address containing the error description. If not\ngiven and **OCIDB_SENTMAILONERROR = 1** the `$_SERVER['SERVER_ADMIN']` variable\ncontents is used as email address.\n\n\n**OCIDB_SENTMAILONERROR [optional]**\n\n- Flag indicating if the class should auto-send emails to the defined EMail\naddress whenever an error occures. Set it to 1 to enable auto-sending,\nand set it to 0 to disable this behavour.\n\n\n**OCIDB_MAIL_EXTRAARGS  [optional]**\n\n- Use this define to pass additional parameter to the `mail()` command in\n`SendmailOnError()`. Some servers might need to set the -f parameter when\nusing PHP's mail() command, and to allow this also here in the class you\ncan use this define. Default is unset.\n\n\n**OCIDB_USE_PCONNECT [optional]**\n\n- if set to 1 persistant connections are used, else standard connects are used.\nThis can be set also on a script-by-script basis via the method `setPConnect()`.\n\n\n**OCIDB_CONNECT_RETRIES [optional]**\n\n- Defines how many connection retries the class should perform before giving up\nwith an appropiate error message. This is useful if your connection to the\ndatabase is of bad quality. The class auto-retries the connection up to the\nnumber you define here. Default value is 1, that means that the class will\nonly try one connection attempt, if this fails an error is generated. This\nis also the behavour of all previous class versions.\n\n\n**OCIDB_CHARSET [optional]**\n\n- Setup a default characterset to be used during the connection. Note that\nthis works Only for Oracle \u003e= 9.2 and PHP 5.1.2+.\nIf this define is not set the NLS_LANG environment variable value is used.\nYou can also override this when using the `connect()` method.\n\n\n\nThe file dbdefs.inc.php is automatically included by the class once you\ninstantiate it the first time. See supplied file for a live example how to\nuse these defines.\n\nTo use the class you have to `require()` first the class code, the rest is done\nautomatically when you first instantiate the class. Normally you may have one\nPHP script which includes several others, here would be the ideal place to put\nthe require() statement for the class, i.e.:\n\n\n````\n// ...Your require() statements\n\nrequire_once(\"path/to/db_oci8.class.php\");\n\n// ..Rest of your code here\n````\n\nOnce this is done and you have added the proper values in dbdefs.inc.php you\ncan now start using the class, this would look like this for example:\n\n````\n\u003c?php\nrequire(\"db_oci8.class.php\");\n\n$db = new \\spfalz\\db_oci8;\n$db-\u003eConnect();\n$mver = $db-\u003eVersion();\n$db-\u003eDisconnect();\necho(\"Your Oracle Server is V\".$mver);\n````\n\n### METHOD OVERVIEW\n\nI've provided an auto-generated method overview inside the docs subfolder of\nthe distribution archive generated by phpDocumentor.\n\nYou'll find below a more detailed overview and description about all existing\nmethods and how to use them. I recommend to read this chapter to get a better\nidea how this all works.\n\nThe class provides the following methods (note that only public methods are\ndocumented):\n\n#### `db_oci8 __construct([string $extconfig = ''])`\n\nThis is the constructor of the class. Before you can use any of the class\nfunctions you have to create a new instance of it.\n\nExample:\n\n`$db = new \\spfalz\\db_oci8;`\n\nYou may also give an alternate path to the database definition file:\n\n`$db = new \\spfalz\\db_oci8(\"/path/to/your/own/dbdefs.inc.php\");`\n\nIf you ommit the path to dbdefs.inc.php the class tries to include this file\nfrom within the same directory where the class resides.\n\n\n#### `integer AffectedRows ()`\n\nReturns the amount of affected rows based on previous DML operation. Note\nthe word DML (Data Manipulation Language) which implies that this method\nonly returns values for INSERT, UPDATE or DELETE commands!\nI also would like to point out that this method relies on the internal row\ncounter of the class. During the way Oracle works it is not that easy to\ndetermine the affected rows, so the class keeps track of this automatically.\n\n\n#### `void clearOutputHash ()`\n\nWhen you are using the OutputHash functionality of `QueryHash()` and the\naccording queries are processed you have to clear the internal output\nhash array. You are responsible to manage this yourself, the class only\nuses the variable.\nIf you forgot to clear the hash it may happen that subsequent calls to\n`QueryHash()` reuse the old data!\n\nSee **examples/test_inout_vars.php** for an example how to use this method.\n\n\n#### `integer Commit ([resource $extstmt = -1])`\n\nCommits the current transaction(s). Please note that this class does not use\n**COMMIT_ON_SUCCESS**, therefor you have to either `commit()` or `rollback()` yourself\nto finish your transactions.\nyou can pass an external oracle connection handle if you want to commit on\nthat handle instead of the internal one.\n\n\n#### `mixed Connect ([string $user = NULL], [string $pass = NULL],[string $host = NULL], [integer $exit_on_error = 1],[string $use_charset = \"\"], [integer $session_mode = -1])`\n\nPerforms connection to an Oracle database server. Normally you do not have to\nsupply here any of the parameters, as these parameters are taken from the\n**dbdefs.inc.php** file automatically.\n\nIf an error occures during the connection attempt the class either returns an\nerror code to the callee (if **DB_ERRORMODE** is set to **DBOF_RETURN_ALL_ERRORS**)\nor prints out an error message and terminates execution.\nIf all goes well this method returns the connection handle. You do not have\nto save this value, the class stores this handle internally and uses this\nhandle whenever you do not supply an handle on your own.\n\nIf you have persistant connections configured the class uses `oci_pconnect()`,\nelse the `oci_connect()` call is used.\n\nIf you have **OCIDB_CONNECT_RETRIES** defined to a value \u003e 1 then the class will\nretry failed connection attempts up to **OCIDB_CONNECT_RETRIES** retries until\nit finally gives up. Default value for **OCIDB_CONNECT_RETRIES** is always 1.\n\nIf you set `$exit_on_error` to 0, the class won't exit in case of an\nconnection error but instead returns the error code to the callee.\n\nYou can pass an character set name to $use_charset which will be used during\nthe connect phase. This is, according to PHP docs, faster than using the\nenvironment variable \"**NLS_LANG**\", so if you have at least Oracle 9i in place,\nconsider using this parameter or set the according global define inside\ndbdefs.inc.php.\n\nThe variable $session_mode can be used to allow connections as **SYSOPER** or\n**SYSDBA** user. However you have to set the PHP.ini parameter\n\"oci8.privileged_connect\" to \"on\" to actually let this work. You can pass\n**OCI_SYSOPER** as constant to connect as **SYSOPER** or **OCI_SYSDBA** to connect as\nSYSDBA user.\nSince PHP 5.3 you can also combine OCI_SYSDBA or OCI_SYSOPER with the\nnew value OCI_CRED_EXT to perform external/OS authentication, if this is\nconfigured in your Oracle instance. Note that OCI_CRED_EXT is not supported\non Windows during security reasons :)\n\n\n#### `array DescTable (string $tablename)`\n\nThis method describes a given table and returns the structure of the table\nas array. The following fields are returned:\n\n- 0 =\u003e Column name\n- 1 =\u003e Column type\n- 2 =\u003e Column size\n- 3 =\u003e Column precision\n\nYou can use the class constants\n\n- \\spfalz\\db_oci8::DBOF_COLNAME\n- \\spfalz\\db_oci8::DBOF_COLTYPE\n- \\spfalz\\db_oci8::DBOF_COLSIZE\n- \\spfalz\\db_oci8::DBOF_COLPREC\n\ninstead of using numeric values if you wish.\n\nPlease note that this method only returns basic informations about the\nstructure of a table, no constraints or other meta informations are returned.\nIf you require more detailed metadata you have to query the according views\nlike USER_TAB_COLUMNS etc.\n\nSee **examples/test_desctable.php** for an example how to use this method.\n\n\n#### `void Disconnect ([mixed $other_sock = -1])`\n\nDisconnects from Oracle database. If no external connection handle is given\nthe class disconnects the internal connection handle, else the supplied one.\nEven when PHP closes automatically all resources when a script terminates it\nis always good programming practise to free all resources you've taken, so\nplease close the connection if you do not need it anymore.\n\n\n\n#### `mixed Execute (mixed $stmt)`\n\nExecutes a cached statement which was previously prepared with `Prepare()`.\n\nThis method returns a result handle which you can use as parameter for the\n`FetchResult()` method call.\nIn case of an error the return code is either an error array (if you have\nset the `$no_exit` parameter to 1 - See `Prepare()`) or the class jumps to the\nstandard error method `Print_Error()` and returns an error code depending on\nthe class setting (either exits or returns ora error number).\n\nNOTE: This function does not support BindVars! Use `ExecuteHash()` instead if\n      you want to use Bindvars in your queries, which is recommended anyway!\n\nSee **examples/test_prep_execute.php** for a complete example how to use\nprepared statements with `ExecuteHash()`.\n\n\n#### `mixed ExecuteHash (mixed $stmt, array $bindvarhash)`\n\nIn fact the same method like `Execute()` but uses bind vars via an associative\narray to pass the values to Oracle.\nExcept the second bindvarhash parameter this method is identical to `Execute()`.\n\nNote that since 1.01 you can also use OutputVar functionality in the same\nway you'll use it with `QueryHash()`. Useful if you `Prepare()` a lot of\nstatements and `ExecuteHash()` them later with the need of Output vars.\n\nSee **examples/test_prep_execute.php** for a complete example how to use\nprepared statements with `ExecuteHash()`.\n\nSee **examples/test_inout_vars.php** for an example how to use Output Vars.\n\n\n#### `array FetchResult ([integer $resflag = OCI_ASSOC], [mixed $extstmt = -1])`\n\nFetches the next data row from the statement. You can either use your own\nstatement handle by passing both values to this method or you can use the\ninternal handle, which is the default. You can specify how you wish to have\nthe returned data organized, either as numeric array (starting with 0) or\nas associative array (the keys are the names of the columns). If no more\ndata exists NULL is returned, so you can easily iterate by using a `while()`\nloop:\n\n````\n\u003c?php\n$db-\u003eQueryResult(\"SELECT ENAME FROM EMP\");\nwhile($data = $db-\u003eFetchResult())\n  {\n  echo(\"Employee: \".$data['ENAME'].\"\u003cbr\u003e\\n\");\n  }\n$db-\u003eFreeResult();\n````\n\nThis method can be used to fetch data from the methods `QueryResult()`,\n`QueryResultHash()`, `Execute()` and `ExecuteHash()`.\n\n\n#### `mixed FreeResult ([mixed $extstmt = -1])`\n\nFrees the statement that was previously allocated by `Prepare()`, `QueryResult()`\nand `QueryResultHash()`. If you did not pass an external statement handle the\nclass frees the internal one. After `FreeResult()` is called the preparsed\nstatement is no longer valid.\n\n\n#### `string GetClassVersion ()`\n\nReturns the class Version. The format of the version string is MAJOR.MINOR\nversionnumber, i.e. \"1.01\".\n\n\n#### `resource GetConnectionHandle ()`\n\nReturns the internally saved connection handle as returned by `Connect()`. This\nis useful if you want to use the oci8_* functions of PHP on an already\nconnected database handle. Returns -1 if no active connection handle exists.\n\n\n#### `integer GetConnectRetries ()`\n\nReturns the current number of retries the class would perform when a\nconnection problem occur. This can be globally set via the dbdefs.inc.php\ndefine \"**OCIDB_CONNECT_RETRIES**\" or via the run-time method `SetConnectRetries()`.\n\n\n#### `integer GetDebug ()`\n\nReturns the current internal debug setting of the class. This value can be\nset via the `SetDebug()` method.\n\n\n#### `integer GetErrorHandling ()`\n\nReturns the current internal error handling setting of the class.\nThis value can be set at run-time via the `SetDebug()` method or globally\nvia the dbdefs.inc.php define **DB_ERRORMODE**.\n\n\n#### `string GetErrorText ([string $exterr = \"\"])`\n\nThis function tries to get the error description for a given error message.\nSimply pass the `$err['message']` field to this function, it tries to\nextract the required informations and call **$ORACLE_HOME/bin/oerr** to\nget the error description.\nIf you omit the passed parameter the class tries to use the internal\n**$sqlerrmsg** string to use.\nIf both the passed string and the internal sqlerrmsg variables are empty this\nfunction returns: \"No error found.\"\n\nSee **examples/functions.inc.php** in `CheckForDBobject()` for an example\nhow to use this method.\nPlease note that this method can only work if you are using either the\nfull client of Oracle or PHP is running on the database server itself!\nThe Instantclient installation of Oracle does not provide the executable\n'oerr' which this method uses, so this method cannot work on a instant client\nbased installation and will return an appropiate error message.\n\n\n#### `static float getmicrotime ()`\n\nInternal function to measure times. Whenever the class performs any action\nagainst the database server the time it took to perform the given action is\ntracked and can be retrieved by calling `GetQueryTime()`. This is useful to\nsee how your queries perform.\n\n\n#### `array GetOutputHash ()`\n\nRetrieves the output hash variable after `QueryHash()` has been called. Before\ngetting the hash you have of course first set this variable by using the\nmethod `SetOutputHash()`. If `QueryHash()` detects such an hash it uses\n`oci_bind_by_name()` to bind the according keys to your query.\n\nSee **examples/test_inout_vars.php** for an example how to use this method.\n\n\n#### `boolean GetPConnect()`\n\nReturns TRUE if the class is configured to use persistant connections, else\nreturns FALSE if normal connections are used. This can be either set globally\nvia dbdefs.inc.php define **OCIDB_USE_PCONNECT** or via the run-time method\n`SetPConnect()`.\n\n\n#### `integer GetQueryCount ()`\n\nReturns the current query counter. Whenever the class performs a query\nagainst the database server an internal counter is incremented. This is\nuseful to track errors, as the `Print_Error()` function dumps out this value,\nmaking it more easy to find the errornous query inside your scripts by simply\ncounting the queries down to the one where the error occures. Just keep in\nmind that the class itself performs one query if you have either\nthe **DB_REGISTER** or **DB_SET_NUMERIC** defines activated. Both require to fire up\na query against Oracle, and therefor the Query counter will be always 1 after\nthe connect call!\n\nSee **examples/functions.inc.php** in function `DBFooter()` for an example.\n\n\n#### `float GetQueryTime ()`\n\nReturns amount of time spend on queries executed by this class.\nThe format is \"seconds.microseconds\".\n\nSee **examples/functions.inc.php** in function `DBFooter()` for an example.\n\n\n#### `array GetSQLError ()`\n\nReturns an associative array with error informations from last query executed.\nThe array has the following structure:\n\n````\n$ehash['err'] =\u003e OCI error code\n$ehash['msg'] =\u003e Complete error description ala ORA-xxxxx: yyyyyyyy\n````\n\n\n#### `mixed Prepare ( $querystring, [ $no_exit = 0])`\n\nPrepares a SQL statement and stores the statement handle in the class'\ninternal cache. These cached statements can be later executed with the\nmethods `Execute()` / `ExecuteHash()`.\nThis is very useful if you use i.e. an INSERT statement inside a loop.\nInstead of calling `Query()` inside the loop, which involves a `oci_parse()`,\n`oci_execute()` and the resulting `oci_fetch()`/`oci_free_statement()` calls you can\nsimply `Execute()` or `ExecuteHash()` the prepared INSERT statement, which is a\nlot faster than `Query()` or `QueryHash()`.\n\nRemember to `FreeResult()` the prepared statements!\n\n\n#### `void PrintDebug (string $msg)`\n\nDepending on the current DEBUG setting the class dumps out debugging\ninformations either on screen, to the error.log of PHP or to both. If debug\nis not enabled this function does nothing. This is extremly useful when\ntracking errors, you can simply call `SetDebug()` with an debug level of your\nchoice before the query in question is executed and the class dumps out the\nqueries, so you can track easily what happens behind the scene.\n\nExample:\n\n````\n..\n$db-\u003eSetDebug(\\spfalz\\db_oci8::DBOF_DEBUGSCREEN);\n$db-\u003eQuery('SELECT FOO FROM BAR WHERE DUMMY=1');\n..\n..\n````\n\nWould result in dumping out the Query on screen.\n\n\n#### `void Print_Error ([string $ustr = ''], [mixed $var2dump = NULL], [integer $exit_on_error = 1])`\n\nThis method serves as the general error handling method inside the class.\nNormally this method dumps out the error occured together with additional\ninformations like used Variables and current query etc. After displaying\nthese informations this method calls `exit()` and terminates execution.\n\nHowever you can modify this behavour with `SetErrorHandling()`. If you have\ndefined `DB_ERRORMODE = \\spfalz\\db_oci8::DBOF_RETURN_ALL_ERRORS` no error message\nis shown, instead the class returns the error code to you, and you have to\nhandle the error conditions on your own.\n\nIf you have set `\\spfalz\\db_oci8::DBOF_SHOW_NO_ERRORS` the class still displays an\nerror message, however the informations shown are limited so that an possible\nattacker does not have all required informations in place to hack your site.\nThis is also default behavour.\nIn development environments it may useful to use the third flag\n`\\spfalz\\db_oci8::DBOF_SHOW_ALL_ERRORS`, in this mode all possible informations are shown\nincluding the query that produces the error and a dump of all passed variables.\n\n\n#### `array Query (string $querystring, [integer $resflag = OCI_ASSOC], [integer $no_exit = 0])`\n\nPerforms a single-row query and returns result, either as numeric or as\nassociative array, depending on the $resflag setting.\nWith the $no_exit flag you can selectively instruct the class NOT to exit\nin case of an error (set to 1), even if your master define **DB_ERRORMODE** has\na different setting.\n\nNOTE: This method no longer supports any bind vars passed as 4th parameter!\n      If you want to use bind vars, use the *Hash() methods provided!\n\nSee **examples/test_query.php** for an example how to use this method.\n\n\n#### `array QueryHash (string $querystring, [integer $resflag = OCI_ASSOC], [integer $no_exit = 0],  [\u0026$bindvarhash = null])`\n\nPerforms a single-row query and returns result as either numeric or\nassociative array. This is pretty much the same method as `Query()`, however\nhere you have to pass the bind variables as associative array.\nThis makes it easier to conditionally add new bind vars to dynamically build\nqueries for example.\n\nExample:\n\n````\n\u003c?php\n..\n..\n$bindvars = array('empno' =\u003e 7900);\n$query    = 'SELECT ENAME,JOB FROM EMP WHERE EMPNO = :empno';\n$result = $db-\u003eQueryHash($query, OCI_ASSOC,0, $bindvars);\n..\n..\n````\n\nAnother feature is the support of output bind variables which are often\nused in PL/SQL procedures to return values to the callee. To use this you\nhave to define an associative array with the name of the output variables\nas keys and the proper output types as values. After you have defined\nthis array you make it visible to the class by calling `SetOutputHash()`.\nThis method has to be called BEFORE you call `QueryHash()`.\nAfter `QueryHash()` returned you can retrieve the result values by calling\n`GetOutputHash()`.\n\nMake sure that you define the output variables in the correct types! If the\noutput variable in PL/SQL defines a string, initialise it with an empty string\nin your hash; if the PL/SQL defines a number, init the hash with the proper\nnumbers presented as 9. If you expect an 10-digit value as return value,\nenter 9999999999 as init value. Larger values as returned are no problem but\nsmaller values will result in ORA-06502 errors!\n\nSee **examples/test_query.php** for an example how to use this method.\n\nSee **examples/test_inout_vars.php** how to use input and output variables when\ncalling PL/SQL code with IN/OUT variables.\n\n\n#### `mixed QueryResult (string $querystring)`\n\nPerforms a multi-row query and returns a statement handle ready to pass to\n`FetchResult()` / `FreeResult()`.\n\nNOTE: This method does no longer support bind vars! If you want to use\n      bind vars, use the `QueryResultHash()` method!\n\nSee **examples/test_queryresult.php** for an example how to use this method.\n\n\n#### `void QueryResultHash (string $query, array \u0026$inhash)`\n\nPerforms a multi-row query and returns a statement handle ready to pass to\n`FetchResult()` / `FreeResult()`. In difference to `QueryResult()` this one supports\nbind variables as an associative array.\n\nSee **examples/test_queryresult.php** for an example how to use this method.\n\n\n#### `integer Rollback ([resource $extstmt = -1])`\n\nPerforms a rollback on the current transaction(s). Please note that this\nclass does not use **COMMIT_ON_SUCCESS**, therefor you have to either `commit()`\nor `rollback()` yourself to finish your transaction(s).\nAlso in case of an error the class always calls `Rollback()` to have a\nconsistent behavour.\nYou can pass an external oracle connection handle to rollback that\ntransaction instead of using the internal connection handle.\nReturns the return code from the `oci_rollback()` call.\n\n\n#### `void SaveBLOB (string $file_to_save, string $blob_table, string $blob_field, string $where_clause)`\n\nThis method allows to save any binary file contents to a given table. You\nhave to pass the full filename of the file to be saved, the name of the\ntable where the BLOB field is defined, the name of the BLOB field itself and\nfinally the condition how to find a specific row, i.e.\n**WHERE ROWID='123456789012345678'**\nTake this method more as an example how to use even complex operations with\nthis class. Normally this method is a perfect candidate to add it into a\nnew class which derives from the db_oci8 class and provides additional\nfunctionality.\nIn the forseen future i will release such a derived class with more methods\nto handle collections and other really Oracle specific stuff.\n\nSee **examples/test_save_blob.php** for an example how to use this method.\n\n\n#### `void SetConnectionHandle (mixed $extsock)`\n\nThis allows to set the class internal socket descriptor to an external value.\nHowever the class protects itself a little bit, meaning if you have already\nperformed a `Connect()` and the internal socket is not zero the class did not\noverride then the internal value with the external one supplied!\n\n\n#### `integer SetConnectRetries (integer $retcnt)`\n\nThe class has support to auto-retry a failed connection. The default value\nfor this retry counter is 1, so that the class will abort as soon as the\nconnection is failed. However sometimes it is more desirable to retry a\nfailed connection up to a configurable limit to bypass network outages etc.\nFor this you can setup the maximum amount of retries the class should\nperform before giving up the connection. You can set this either globally\nvia the dbdefs.inc.php define \"**OCIDB_CONNECT_RETRIES**\" or set it at run-time\nvia this method. This method returns the old retry counter previously set.\n\n\n#### `void SetDebug (integer $state)`\n\nThis method allows debugging of SQL Queries inside your scripts.\n\n$state can have these values:\n\n- **\\spfalz\\db_oci8::DBOF_DEBUGOFF**    = Turn off debugging\n- **\\spfalz\\db_oci8::DBOF_DEBUGSCREEN** = Turn on debugging on screen (every Query will be dumped on screen)\n- **\\spfalz\\db_oci8::DBOF_DEBUFILE**    = Turn on debugging on PHP errorlog\n\nYou can mix the debug levels by adding the according defines.\n\n\n#### `void SetErrorHandling (integer $val)`\n\nAllows to set the class handling of errors.\n\n- **\\spfalz\\db_oci8::DBOF_SHOW_NO_ERRORS**    = Show no security-relevant informations\n- **\\spfalz\\db_oci8::DBOF_SHOW_ALL_ERRORS**   = Show all errors (useful for development)\n- **\\spfalz\\db_oci8::DBOF_RETURN_ALL_ERRORS** = No error/autoexit, just return the Oracle error code.\n\n\n#### `string SetModuleAction (string $module, [string $action = \"\"], [boolean $returnURL = FALSE])`\n\nRegisters the name and optionally the action to Oracle either through the\nuse of the PL/SQL package \"**DBMS_APPLICATION_INFO**\" or via the new PHP 5.3.2\nfunctions `oci_set_module_name()` and `oci_set_action()`.\nThe value of $module will be set as MODULE name, while the optional $action\nvalue will be set as Module's current action.\n\nIf PHP 5.3.2+ is in use, an empty string is returned from this method.\n\nIn previous versions of PHP 5.3.2 the parameter $returnURL decides what\nwill be returned. If set to default value (FALSE) this method will build\nthe necessary PL/SQL call to register the $module and optionally the $action\nvalue and calls it directly via `QueryHash()`.\nIf $returnURL is set to TRUE, the PL/SQL call is build but not send to the\ndatabase, but instead returned to the callee as string.\n\nThis method is used in the `Connect()` method to register the application\nname to Oracle during the connect phase.\n\n\n#### `void SetOutputHash ( array $outputhash)`\n\nUse this call before using `QueryHash()` to pass the output hash variable\nto the class. This is only required if you are using either PL/SQL OUT variables\nor \"RETURNING INTO\" clauses in your queries.\nAfter successful completition of `QueryHash()` or `ExecuteHash()` the results\ncan be retrieved by calling `getOutputHash()`.\n\nSee **examples/test_inout_vars.php** for an example how to use this method.\n\n\n#### `boolean SetPConnect ( $conntype)`\n\nChange the connection method to either persistant connections or standard\nconnections.\n\nSet $conntype = TRUE to activate persistant connections.\n\nSet $conntype = FALSE to deactivate persistant connections.\n\nDefault is standard connection.\n\n\n#### `boolean SetPrefetch (integer $rows, [mixed $extstmt = -1])`\n\nAllows to set the initial prefetch of rows that Oracle performs. Default is\n1 row. If your application fetches a lot of datarows it might be useful to\nset this to a higher value, i.e. 10 or more. If you want a specific connection\nhandle to change you can pass the connection identifier as second parameter\nto this method, if nothing is given the currently active connection is used.\n\n\n#### `void SQLDebug ( $state)`\n\nAllows to en- or disable the SQL_TRACE feature of Oracle.\nPass TRUE to enable or FALSE to disable. When enabled all statements of your\nsession are saved in a tracefile stored in\n\n`$ORACLE_BASE/admin/\u003cDBNAME\u003e/udump/*.trc`\n\nAfter your session disconnects use the tkprof tool to generate human-readable\noutput from the tracefile, i.e.:\n\n`$\u003e tkprof oracle_ora_7527.trc out.txt`\n\nNow read '**out.txt**' and see what happen inside Oracle during your session.\n\n\n#### `string Version ()`\n\nReturns Database Versionstring. If no active connection exists when calling\nthis function this method connects itself to the database, retrieve the\nversion string and disconnects afterwards. If an active connection exists\nthis connection is used and of course not terminated.\n\n\n#### `boolean SetAction ($action)`\n\nSets the action name for Oracle tracing.\n\nThis method simply call the PHP function `oci_set_action()` when running on\nPHP 5.3.2 or newer, else TRUE is returned and nothing is done.\n\n\n#### `boolean SetClientInfo($cinfo)`\n\nSets the client information for Oracle tracing.\n\nThis method simply call the PHP function `oci_set_client_info()` when running on\nPHP 5.3.2 or newer, else TRUE is returned and nothing is done.\n\n\n#### `boolean SetClientIdentifier($identifier)`\n\nSets the client identifier for Oracle tracing.\n\nThis method simply call the PHP function `oci_set_client_info()` when running on\nPHP 5.3.2 or newer, else TRUE is returned and nothing is done.\n\n\n### FINAL WORDS AND CONTACT ADDRESS\n\nI'm using this class now in all my Oracle related projects and never encountered\nany problems. However we all know that no software is 100% bugfree, so if you\nhave found a bug or have suggestions or feature requests feel free to contact\nme under one of the following addresses:\n\n  WWW: http://www.saschapfalz.de/contact.php\n\nEMAIL: php at saschapfalz dot de\n\n\nA big thanks must go to the following people:\n\n- Andreas L. for providing very good ideas how to improve the class\n- Sven W. for helping finding bugs\n- DOAG for giving me the opportunity to perform my first speaking about PHP/Oracle\n\n-----------------------------------------------------------------------[EOF]-\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsiegel2k16%2Fdb_oci8","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsiegel2k16%2Fdb_oci8","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsiegel2k16%2Fdb_oci8/lists"}