Php connection to oracle Database code

Source: Internet
Author: User
Php connection to oracle Database code

Php connection to oracle Database code

Php connection to oracle Database code

Connect to oracle 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 );
/*
Note:
By default, php cannot be connected to the oracle database. We have to modify it in the Windows Extensions section of php. ini
Extension_dir = "file path of the dll to be loaded" (for example, c: phpextensions)
Extension = php_oci8.dll
Extension = php_oracle.dll
Step 2:
Set isapi in iis

*/

// Php connection to the oracle database Code 2

If ($ conn = Ora_Logon (""))
{
Echo "SUCCESS! Connected to databasen ";
}
Else
{
Echo "Failed:-(cocould not connect to databasen ";
}
Ora_Logoff ($ conn );

// Connect to database instance 3

$ Connection = Ora_Logon ("", "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 );

/*
Function Description:
Integer ora_logon (string user, string password) connects to the oracle database server based on the specified user
Query the connection provided by integer ora_open (integer connection. PHP generates an indicator to parse the query
Integer ora_do (integer connection, string query) is queried and ready for execution
Query parsed by the integer ora_parse (integer cursor, string query) ora_parse function.

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.