<?php
include_once('db.php');
/******************************************************************************
use array
/******************************************************************************/
$config = array(
'class' => 'mysql',
'host' => 'localhost',
'port' => '3306',
'sock' => false,
'user' => 'root',
'pass' => '',
'base' => 'test',
'coll' => 'utf8',
);
try{
$result = db($config)->q('select * from `wordlist`');
print_r($result);
echo("\nFields: " . db()->f());
echo("\nRows: " . db()->r());
echo("\nCounter: " . db()->i());
echo("\nTimer: " . db()->t());
}
catch(db_Exeption $e){
echo($e->getMessage() . ' on line ' . $e->getLine() . "\n");
}
/******************************************************************************
OR use JSON-encoded string
/******************************************************************************/
$db_config = '{"class":"mysql","host":"localhost","port":"3306","sock":false,"user":"rootuser","pass":"password","base":"zlioxygon","coll":"utf8"}';
try{
$result = db($db_config)->q('select * from `wordlist`');
print_r($result);
echo("\nFields: " . db()->f());
echo("\nRows: " . db()->r());
echo("\nCounter: " . db()->i());
echo("\nTimer: " . db()->t());
}
catch(db_Exeption $e){
echo($e->getMessage() . ' on line ' . $e->getLine() . "\n");
}
/******************************************************************************
OR use JSON-encoded file
/******************************************************************************/
try{
$result = db('db_config.json')->q('select * from `wordlist`');
print_r($result);
echo("\nFields: " . db()->f());
echo("\nRows: " . db()->r());
echo("\nCounter: " . db()->i());
echo("\nTimer: " . db()->t());
}
catch(db_Exeption $e){
echo($e->getMessage() . ' on line ' . $e->getLine() . "\n");
}
/******************************************************************************
OR use class
/******************************************************************************/
try{
$result = db()->q('select * from `wordlist`');
print_r($result);
echo("\nFields: " . db()->f());
echo("\nRows: " . db()->r());
echo("\nCounter: " . db()->i());
echo("\nTimer: " . db()->t());
}
catch(db_Exeption $e){
echo($e->getMessage() . ' on line ' . $e->getLine() . "\n");
}
/******************************************************************************/
|