How to invoke three kinds of databases in PHP (3)

Source: Internet
Author: User
Tags insert integer connect oracle database
Data | Database Oracle (ORACLE) is the most popular relational database in the world. It is a powerful engine of industrialization promoted by large corporations. Let's take a look at its related functions:

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

Start a connection to an Oracle database server.

(2) integer ora_open (integer connection)

Opens the cursor for the given connection.

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

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

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

Resolves a query and is ready to execute.

(5) Boolean ora_exec (integer cursor)

Executes a query that was 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 to the indicator. This allows you to call the Ora_getcolumn function.

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

Returns the current value. The zero-based numeric index of the column.

(8) Boolean ora_logoff (integer connection)

Disconnect the database server.

The following is a sample program for inserting data into an Oracle database:



<body>

<form action= "<?echo $PHP _self;? > "method=" Post >

<table border= "1" cellspacing= "0" cellpadding= "0" >

<tr>

<th>ID</th>

<th>name</th>

<th>Description</th>

</tr>

<tr>

<td><input type= "text" name= "name" Maxlength= "a" size= "ten" ></td>

<td><input type= "text" name= "email" maxlength= "255" size= "></td>"

<td><input type= "text" name= "Description" maxlength= "255" size= "M" ></td>

</tr>

&LT;TR align= "center" >

&LT;TD colspan= "3" ><input type= "Submit" value= "Submission" > <input "reset" type= "rewrite" ></td>

</tr>

</table>

</form>

?

Set two environment variables first ORACLE_HOME,ORACLE_SID

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

Putenv ("Oracle_sid=ora8");

Set up a Web page to display Chinese

Putenv ("nls_lang=simplified_chinese.zhs16cgb231280");

if ($connection =ora_logon ("Scott", "Tiger")) {

Library table test has id,name,description three items

$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);

$content 0=ora_getcolumn ($cursor, 0);

$content 1=ora_getcolumn ($cursor, 1);

$content 2=ora_getcolumn ($cursor, 2);

Print ("$content 0");

Print ("$content 1");

Print ("$content 2");

Ora_close ($cursor);

}

Ora_logoff ($connection);

}

?>

</body>




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.