How to use the Oracle database in PHP (1), read how to use the Oracle database in PHP (1), php and above, built in almost all the current database processing functions, including Oracle. in this article, we use an instance to introduce how to use these functions to operate Oracle databases. PHP provides two major types of APIs (application interfaces) for Operation "> <LINKhre in php3.0 and later versions, php has built in almost all database processing functions, including Oracle; in this article, we use an instance to introduce how to use these functions to operate Oracle databases.
PHP provides two types of APIs (application interfaces) to operate Oracle databases. One is the standard Oracle processing function (ORA) and the other is the Oracle 8 Call Interface function (OCI8). The latter can only be used in Oracle 7 or 8 versions. Because OCI8 provides many optimization options, the OCI8 interface should be used whenever possible. Here we use these two function sets for demonstration.
First, the premise of this article is that you have installed the Oracle database environment and the PHP development environment. if you do not understand it, it doesn't matter much. There are many good articles on the Internet for reference.
Step 1: create a database for the experiment
You can ask your database administrator or refer to the Oracle User manual for troubleshooting.
Create a data table with ORA
Even if you have created a data table, take a look at the text section. It tells you how to use PHP + SQL technology to operate Oracle
In this example, a data table is created to store personal email addresses.
To process the Oracle database, we must first establish a connection with Oracle.
The syntax is Ora_Logon (user, password). return a connectID ..
Note: Before that, we must set the value of the environment variable ORACLE_SID.
Now, we can perform interactive operations on Oracle using the join ID. The data table name is email_info. The table consists of two domains, one for storing the full name of the individual, (for example: Xiaoyue) one for storing the e-mail address such as (xiaoyue@163.net)
You also need a cursor Ora_Open. This cursor is often used to enumerate data. We use Ora_Parse or Ora_Exec to query the result set of Oracle. Ora_Parse to verify the correctness of the SQL syntax, while Ora_Exec executes the corresponding SQL statement. If all the operations are normal, we will run Ora_Commit to confirm.
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.