Login   Register  
PHP Classes
elePHPant
Icontem

File: documentation/multiple-databases.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Camilo Sperberg  >  Extended MySQLi  >  documentation/multiple-databases.php  >  Download  
File: documentation/multiple-databases.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Extended MySQLi
MySQL database access wrapper using MySQLi
Author: By
Last change:
Date: 2013-09-18 11:21
Size: 990 bytes
 

Contents

Class file image Download
<?php

include('../config.php');
include(
'../db_mysqli.class.php');

try {
    
$db1 = new \u4u\db_mysqli();
    print(
'Version connection 1: '.$db1->version());
} catch (\
Exception $e) {
    print(
'::1:: '.$e->getMessage());
}

print(
'<br />');

try {
    
$db2 = new \u4u\db_mysqli();
    
$db2->registerConnection('db_mysqli_v401');
    print(
'Version connection 2: '.$db2->version());
} catch (\
Exception $e) {
    print(
'::2:: '.$e->getMessage());
}

print(
'<br />');

try {
    
$db3 = new \u4u\db_mysqli();
    
$db3->registerConnection('mysql''localhost''root');
    print(
'Version connection 3: '.$db3->version());
} catch (\
Exception $e) {
    print(
'::3:: '.$e->getMessage());
} catch (\
ErrorException $e) {
    print(
'::4:: '.$e->getMessage());
}

$res1 $db1->query('SHOW TABLES');
$res2 $db2->query('SHOW TABLES');

var_dump($res1);
var_dump($res2);

$res1 $db1->query('SHOW DATABASES');
$res2 $db3->query('select * from user');

var_dump($res1);
var_dump($res2);