PHP Classes

File: example-cached_db.php

Recommend this page to a friend!
  Classes of marcelo entraigas   Simple DB   example-cached_db.php   Download  
File: example-cached_db.php
Role: Example script
Content type: text/plain
Description: cached db example
Class: Simple DB
Store and retrieve data from a MySQL database
Author: By
Last change: Accessible without user login
Date: 15 years ago
Size: 729 bytes
 

Contents

Class file image Download
<?php
 
/**
  * This is an advanced example of using the Database class
  */

    # default database configuration
   
$cfg_resource['default'] = array(
       
'server' => 'localhost',
       
'database' => 'tradeaxes',
       
'user' => 'tradeaxes',
       
'pass' => 'tradeaxes',
       
'cache_ttl' => 300,
       
'cache_path' => '',
       
'cache_prefix' => 'db_',
    );

   
#main includes
   
require_once('class.Error.php');
    require_once(
'class.Database.php');

   
#create a db object
   
$db1 = new CachedDB();
   
$db2 = new CachedDB();
   
   
#select all records from users
   
$sql = "SELECT * FROM users";
   
$db1->query($sql);
   
   
print_r($db2->get_all($sql));
   
   
#finally, show posible errors...
   
echo $db2->getErrors();
?>