PHP connects to Oracle and simple operations
To enable your PHP to support Oracle, follow these steps:
1. Install PHP environment, find Appserv or XAMPP, one-click installation, very convenient
2. Copy the Php_oci8.dll from the Ext directory of PHP to the system32 directory
3. Modify the configuration in the php.ini file, remove the extention = php_oci8.dll, remove the preceding semicolon
4. Restart Apache
Two ways to establish links with Oracle database
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 way not, using the second, the inside of a few parameters are user name, password, Oracle service address, where test is the service name.
$sql = "SELECT * FROM Table_exmaple"
$ora _test = Oci_parse ($conn, $sql); Compiling SQL statements
Oci_execute ($ora _test,oci_default); Perform
while ($r =oci_fetch_row ($ora _test))//Retrieve results
{
echo $ora _test[0];
echo "
";
}