How to connect PHP and Oracle without using the OCI8 interface
Source: Internet
Author: User
As the scope 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 visit Oracle becomes more and more important. I wrote a simple iERP system to talk about how I did it. as the scope of the website expands, MySql obviously cannot meet the requirements.
When a large database is used in Oracle, it is more and more important to use PHP to visit Oracle.
I wrote a simple iERP system to talk about how I did it, and explained it in the official PHP Manual.
Generally, most people use Oracle8 Call-Inte *** ce (OCI8) to connect to the database,
I will not apply the OCI8 interface but directly apply the Oracle function of PHP to connect to the database and process data. Note:
Php. ini configuration should be dropped; the semicolon before extension = php_oracle.dll is
Extension = php_oracle.dll 1, connect to the database application ora_logon () or ora_plogon () to connect to the database
Ora_plogon functions are similar to ora_logon, except that ora_plogon enables long-term connection with Oracle.
Until the web service ends $ handle = ora_plogon ('system @ localhost', 'manager') or die;
In '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. closed cursor
Ora_close ($ cursor); of course, you may perform the following steps:
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 ('20140901', '20160901 ')';
Ora_parse ($ cursor, $ query) or die;
Ora_exec ($ cursor );
Ora_close ($ cursor );
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service