In php3.0 above, PHP has nearly all of the current database processing functions, including Oracle; In this article we have an example of how to use these functions to manipulate Oracle databases.
PHP provides 2 classes 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 on Oracle 7 or 8 versions. Because OCI8 offers a number of optimization options, the OCI8 interface should be used whenever possible. Here we demonstrate each of these two function sets.
First of all this article assumes that you have installed the Oracle database environment and the PHP development environment. If you do not know how much relationship, there are a lot of relevant good articles on the internet can be referenced.
First step: Create an experimental database
This problem you can ask your database administrator or refer to the Oracle User manual processing, here no more talk
Set up data tables with ORA
Even if you have already created the datasheet, please look at the text of this paragraph. It can tell you how to operate Oracle with PHP+SQL technology.
In this case, we created a data table for storing personal emails.
To handle Oracle databases, we first have to establish a connection with Oracle.
The syntax is ora_logon (user, password), which returns a Connectid.
Reminder: Before this we must also set the environment variable: ORACLE_SID value.
Now we can interact with Oracle through the ID of the join. The name of the data sheet is called Email_info. The table consists of 2 domains, one storage personal name, (such as: both) a storage email address such as (xiaoyue@163.net)
A cursor Ora_open is also required. This cursor is often used to enumerate data. We query Oracle's result set with Ora_parse or ora_exec. Ora_parse the correctness of the SQL syntax and ora_exec executes the corresponding SQL statement. If all this works, then we'll run ora_commit to confirm it.
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.