PHP Tutorials Connect Oracle Database Tutorial code
$conn = Ocilogon ("Scott", "Tiger", "Your Oracle database name");
$stmt = Ociparse ($conn, "select Empno, ename from emp");
* * Use ocidefinebyname before executing ociexecute
Ocidefinebyname ($stmt, "EMPNO",& $empno);
Ocidefinebyname ($stmt, "ename",& $ename);
Ociexecute ($stmt);
while (Ocifetch ($stmt)) {
echo "Empno:". $empno. " n ";
echo "ename:". $ename. " n ";
}
Ocifreestatement ($stmt);
Ocilogoff ($conn);
/*
Indicate:
PHP is not connected to the Oracle database by default, we have to modify the Windows Extensions section in php.ini to
Extension_dir = "File path of the DLL to be loaded" (such as C:phpextensions)
Extension=php_oci8.dll
Extension=php_oracle.dll
Step Two:
Setting up ISAPI in IIS
*/
Two
if ($conn =ora_logon ("User@tnsname", "password"))
{
echo "SUCCESS! Connected to Databasen ";
}
Else
{
echo "Failed:-( Could not connect to Databasen ";
}
Ora_logoff ($conn);
Connecting to database instance three
$connection = Ora_logon ("webmaster@111cn.net", "123");
if ($connection = = False) {
echo Ora_errorcode ($connection). ":". Ora_error ($connection). "";
Exit
}
$cursor = Ora_open ($connection);
if ($cursor = = False) {
echo Ora_errorcode ($connection). ":". Ora_error ($connection). "";
Exit
}
Ora_commit ($connection);
Ora_close ($cursor);
Ora_logoff ($connection);
/*
Description function function:
integer ora_logon (string user, string password) to connect to an Oracle database server based on a specified user
Executes the query on the connection given by the integer ora_open (integer connection). PHP generates an indicator that parses the query
integer ora_do (integer connection, string query) for the query and is ready to execute
integer ora_parse ( Integer cursor, string query) Ora_parse the query that the function resolved.