PHP Connects Oracle Database code

Source: Internet
Author: User

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.

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.