Do not use the OCI8 interface to connect PHP to Oracle. As the scale of the website expands, MySql obviously cannot meet the requirements. in the case that many websites use a large database Oracle, how to use PHP to access Oracle becomes more and more important. As the scale of my website expands, MySql obviously cannot meet the requirements.
When using a large database of Oracle, it becomes more important to use PHP to access Oracle.
I wrote a simple iERP system to talk about how I did it. it is also described in the official PHP Manual.
Generally, most people use Oracle8 Call-Interface (OCI8) to connect to the database,
I will introduce how to connect to the database and process data directly using Oracle functions of PHP without using the OCI8 interface.
Note:
In the php. ini configuration, remove the semicolon before extension = php_oracle.dll.
Extension = php_oracle.dll
1. connect to the database
Use ora_logon () or ora_plogon () to connect to the database
Ora_plogon is similar to ora_logon, except that ora_plogon enables long-term connection with Oracle.
Until the web service is stopped
$ Handle = ora_plogon ("system @ localhost", "manager") or die;
"System @ localhost", localhost is the oracle SID name, system is the user name, and manager is the user password.
2. open the cursor.
$ Cursor = ora_open ($ handle );
3. analyze the syntax and execute the command
$ Query = "select count (*) from area where areacode = $ addcode ";
Ora_parse ($ cursor, $ query) or die;
Ora_exec ($ cursor );
4. get data
If (ora_fetch ($ cursor ))
$ Datacount = ora_getcolumn ($ cursor, 0 );
5. close the cursor.
Ora_close ($ cursor );
Of course, you may execute the delete or insert statement without the steps for getting data, such:
INSERT :( INSERT)
$ Handle = ora_plogon ("system @ localhost", "manager") or die;
Ora_commiton ($ handle );
$ Cursor = ora_open ($ handle );
$ Query = "insert into area (areacode, areaname) values ($ addcode, $ addname )";
Ora_parse ($ cursor, $ query) or die;
Ora_exec ($ cursor );
Ora_close ($ cursor );
DELETE: (DELETE)
$ Handle = ora_plogon ("system @ localhost", "manager") or die;
$ Cursor = ora_open ($ handle );
Ora_commiton ($ handle );
$ Query = "delete from area where areacode in (222,444 )";
Ora_parse ($ cursor, $ query) or die;
Ora_exec ($ cursor );
Ora_close ($ cursor );
With the use of large databases in Oracle, it becomes more important to use PHP to access Oracle. From...