Login   Register  
PHP Classes
elePHPant
Icontem

File: example.txt

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  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: 2003-04-22 21:25
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() > ) {
            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>