PHP Classes

File: example.txt

Recommend this page to a friend!
  Classes of Thomas Werner   DBI   example.txt   Download  
File: example.txt
Role: Example script
Content type: text/plain
Description: DBI Example
Class: DBI
Author: By
Last change: require -> include
Date: 21 years ago
Size: 959 bytes
 

Contents

Class file image Download
<html>

    <head>
        <title>DBI DEMO</title>
        <?php
             
             
// Configuration File
             
if( ! $GLOBALS['lib_config_read'] ) {
                  include(
'lib_config.class');
              }
             
             
/* Database Interface */
             
if( ! $GLOBALS['lib_dbi_read'] ) {
                  include(
'lib_dbi.class');
              }
             
             
$config = new CONFIG;
             
             
$dbh = new DBI;

       
?>
</head>

    <body>
       
    <?php
       
/* Edit Config-File 'lib_config.class' for dbname/dbuser/dbpwd */
       
$dbh->connect();

       
$dbexec = $dbh->prepare("SELECT * FROM table");
        if (
$dbexec->execute() && $dbexec->rows() > 0 ) {
            while (
$row = $dbexec->fetchrow_hashref() ) {
                echo
"Firstname: {$row->FIRSTNAME} Lastname: {$row->LASTNAME}";
            }
        }
        else {
            echo
"Failure";
        }
       
       
/* More Obj Methods
            $dbh->pconnect();
            $dbexec->insert_id();
            $dbexec->finish();
            $dbexec->fetchrow_array();
            $dbexec->fetchrow_hash();
        */
   
?>

    </body>

</html>