Login   Register  
PHP Classes
elePHPant
Icontem

File: example.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of LUIS MORALES  >  DB factory extension  >  example.php  >  Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example to use DB factory extension class
Class: DB factory extension
Simplified extension of PEAR::DB abstraction layer
Author: By
Last change: Add specific help for the databases
Date: 2006-02-22 05:49
Size: 803 bytes
 

Contents

Class file image Download
<?
require_once "db.class.php";

// example to connect remember to replace the $MDB parameters by yours parameters
// your_ip_db_server : is the db server for mysql, postgres and odbtp database

$MDB = array ();
$MDB['type'] = '';
$MDB['host'] = 'your_ip_db_server';
$MDB['user'] = 'myuser';
$MDB['password'] = 'mypass';
$MDB['dbname'] = 'mydb';

$q = array ();
$q['mysql'] = "select now()"//query for mysql
$q['psql'] = "select now()";  //query for psql
$q['odbtp(mssql)'] = "select getdate()"//query for mssql over odbtp

$db = new mdb;

foreach(
$q as $k => $v){
  
$MDB['type'] = $k;
  echo 
"{$k} : {$v} <br>";
  if(
$db->db_dbArray($MDB$v)){    
    
var_dump($db->_db['data'][0]);
    echo 
"<hr>";
  }else{
    echo 
$db->_db['debug'];
    echo 
"<hr>";
  }  
}

?>