Php connection to oracle and simple operations

Source: Internet
Author: User
Php connection to oracle and simple operations enable your php to support oracle. follow these steps: 1. to install the php environment, find appserv or xampp and install it with one click. 2. copy php_oci8.dll under the ext directory of php to the system32 directory. modify php. remove & nb php from the configuration in the INI file to connect to oracle and perform simple operations.

To enable your php to support oracle, follow these steps:

1. install the php environment. find appserv or xampp and install it with one click, which is very convenient.

2. copy php_oci8.dll under the ext directory of php to the system32 directory.

3. modify the configuration in the php. ini file and remove it. extention = php_oci8.dll and remove the semicolon

4. restart apache


Connect to the oracle database in two ways

1. $ conn = oci_connect ('username', 'password', "(DEscriptION = (ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.1.100) (PORT = 1521 )) (CONNECT_DATA = (SID = test )))");

2. $ conn = oci_connect ('username', 'password', '192. 168.1.100/test ');

Sometimes the first method does not work. The second method uses the following parameters: user name, password, and oracle service address. test is the service name.


$ SQL = "select * from table_exmaple"

$ Ora_test = oci_parse ($ conn, $ SQL); // compile an SQL statement

Oci_execute ($ ora_test, OCI_DEFAULT); // execute

While ($ r = oci_fetch_row ($ ora_test) // Retrieve the result
{
Echo $ ora_test [0];
Echo"
";
}

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.