PHP methods for calling three databases (3)

Source: Internet
Author: User
PHP calls three database methods (3). Read the PHP call methods for three databases (3). Oracle is the most popular relational database in the world. It is a powerful engine of industrialization promoted by large companies. Let's take a look at the related functions: (1) integerora_logon (stringuser, stringpassword) start an Oracle data ">

Oracle is the most popular relational database in the world. It is a powerful engine of industrialization promoted by large companies. Let's first look at its related functions:

(1) integer ora_logon (string user, string password)

Start the connection to an Oracle database server.

(2) integer ora_open (integer connection)

Open the cursor of the given connection.

(3) integer ora_do (integer connection, string query)

Execute the query on the given connection. PHP generates an indicator, parses the query, and executes it.

(4) integer ora_parse (integer cursor, string query)

Parse a query and prepare it for execution.

(5) boolean ora_exec (integer cursor)

Execute a query previously parsed by the ora_parse function.

(6) boolean ora_fetch (integer cursor)

This function causes the rows in a executed query to be taken into the indicator. This allows you to call the ora_getcolumn function.

(7) string ora_getcolumn (integer cursor, integer column)

Returns the current value. A numeric index with a column starting from zero.

(8) boolean ora_logoff (integer connection)

Disconnect the database server.

The following is an example program for inserting data into an ORACLE database:



Insert data to an ORACLE database






// Set two environment variables ORACLE_HOME and ORACLE_SID first

Putenv ("ORACLE_HOME =/oracle/app/oracle/product/8.0.4 ");

Putenv ("ORACLE_SID = ora8 ");

// Set Chinese characters for the webpage

Putenv ("NLS_LANG = Simplified_Chinese.zhs16cgb231280 ");

If ($ connection = ora_logon ("scott", "tiger ")){

// The database table test has three items: ID, name, and Description.

$ SQL = 'Insert into test (ID, name, Description) values ';

$ SQL. = '(''. $ ID.'', ''. $ name.'', ''. $ Description .'')';

If ($ cursor = ora_do ($ connect, $ SQL )){

Print ("insert finished! ");

}

$ Query = 'select * from test ';

If ($ cursor = ora_do ($ connect, $ query )){

Ora_fetch ($ cursor );

$ Content0 = ora_getcolumn ($ cursor, 0 );

$ Content1 = ora_getcolumn ($ cursor, 1 );

$ Content2 = ora_getcolumn ($ cursor, 2 );

Print ("$ content0 ");

Print ("$ content1 ");

Print ("$ content2 ");

Ora_close ($ cursor );

}

Ora_logoff ($ connection );

}

?>



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.