PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of Outdated profile   dbsource   example.php   Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example on how to use this classes
Class: dbsource
Class to easily access different databases
Author: By
Last change:
Date: 21 years ago
Size: 1,219 bytes
 

Contents

Class file image Download
<?

   
include "dbsource.inc.php";
    include
"dbsource_mysql.inc.php";
    include
"dbsource_oracle.inc.php";

   
// Creates an object for handling a connection to mysql
   
$db_mysql = new dbsource_mysql
                                 
(
                                   
"hostname",
                                   
"user",
                                   
"password",
                                   
"database"
                                 
);
                                 
   
// Creates an object for handling a connection to oracle
   
$db_oracle = new dbsource_oracle
                                 
(
                                     
"user",
                                   
"password",
                                   
"schema"
                                 
);
   
   
// Connect the mysql object to the database
   
$db_mysql->connect ();
   
// Make a simple query to the mysql database
   
$db_mysql->query ("select * from table");
   
// And show some results
   
while ($row = $db_mysql->fetchrow ())
        echo
$row["field"];
   
   
// And exactly the same for the oracle object
   
$db_oracle->connect ();
   
$db_oracle->query ("select * from table");
    while (
$row = $db_oracle->fetchrow ())
        echo
$row["field"];
   
   
// It also gives a simple debug tool to show html-formatted sql sentences
   
$db_oracle->querydebug ("select * from table where field like '%value%' and field2 = 2500;");
       
   
// Any contributions for other databases will be welcomed at lha@hexoplastia.com

?>