With PHP you can easily connect to the database, request the data and display it in your Web site, or even modify the data in the database. MySQL is a very popular database, and there are many tutorials about PHP and MySQL on the internet. MySQL is free, which may attract a lot of people. Because of its wide application, I do not want to repeat the use of MySQL here. Oracle is heavily used in enterprise applications, so we use Oracle to introduce PHP's connection to the database. We certainly don't mention the Oracle database design because it's beyond the scope of our discussion.
PHP provides two sets of functions that are connected to Oracle, namely the Ora_ and OCI functions. Where the Ora_ function is slightly stale. The OCI function update is said to be better. The use of the syntax is almost the same. As mentioned earlier, your PHP installation options should be able to support both use.
For more information on installing the PHP3 Apache server on a Microsoft Windows platform and more about Oracle databases, consult the following url:www.csoft.net/~vsbabu/articles/oraphp.html.
4.1 Connections
if ($conn =ora_logon ("User@tnsname", "password"))
{
echo "SUCCESS! Connected to database\n ";
}
Else
{
echo "Failed:-( Could not connect to database\n ";
}
Ora_logoff ($conn);
Phpinfo ();
?>
The above code connects to the database using the Oracle database name, user name, and password defined by Tnsname (indicated in your Tnsnames.ora file). On the basis of a successful connection, the Ora_logon function returns a Non-zero connection ID and stores it in the variable $conn.
4.2 Query
Assuming the database is already connected, let's actually apply the query to the database. The following code shows a typical example of a connection and query:
The following is a reference fragment:
/*
* Connect to the database and execute the query
*/
function Printoraerr ($in _cur)
{
Check Oracle for errors
Display if there is an error
Call this function every time Oracle is requested when the pointer is activated
1 2 3 4 5 Next > Full text reading tips: Try the "←→" button, turn the page more convenient Oh!