PHP Classes
Icontem

File: tbssql_demo.php


  Search   All class groups All class groups   Latest entries Latest entries   Top 10 charts Top 10 charts   Newsletter Newsletter   Blog Blog   Forums Forums   Help FAQ Help FAQ  
  Login   Register  
Recommend this page to a friend! ReTweet ReTweet Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Skrol29  >  TbsSQL  >  tbssql_demo.php  
File: tbssql_demo.php
Role: Example script
Content type: text/plain
Description: Demo that display some info about your db
Class: TbsSQL
Database access abstraction layer
 

Contents

Class file image Download
<?php

    
echo "* TbSQL demo: <br />\r\n";

  
// Include TbsSQL in order to use it..
  
include_once('tbssql_mysql.php');
  
  
// Connection with a global variable which will be destroyed
  
$con_info = array('srv'=>'localhost','uid'=>'root''pwd'=>'''db'=>'mysql');
    
$Db = new clsTbsSQL('con_info'); // $con_info is destroyed. Also available: $Db = new clsTbsSQL('localhost','root','','mysql');

    // Retrieve a single value
    
$now $Db->GetVal('SELECT NOW()');
    echo 
"-> <b>Current time:</b> {".$now."} <br />\r\n";

    
// Using text argument
    
$text "that's true";
    
$now $Db->GetVal('SELECT @1@',$text);
    echo 
"-> <b>Text:</b> {".$text."} <br />\r\n";

    
// Using numeric argument
    
$numeric 29.54;
    
$now $Db->GetVal('SELECT %1%',$numeric);
    echo 
"-> <b>Numeric:</b> {".$numeric."} <br />\r\n";

    
// Retrieve a single row
    
$row $Db->GetRow('SHOW TABLES');
    echo 
"-> <b>Single row:</b> ".var_export($row,true)." <br />\r\n";

    
// Retrieve all rows
    
$rows $Db->GetRows('SHOW TABLES');
    echo 
"-> <b>All row:</b> ".var_export($rows,true)." <br />\r\n";

    
// Retrieve a list of values
    
$list $Db->GetList('SHOW TABLES');
    echo 
"-> <b>List of values:</b> ".var_export($list,true)." <br />\r\n";

    
// Rows affected by the last SQL action
    
$n $Db->AffectedRows();
    echo 
"-> <b>Affected rows:</b> ".$n." <br />\r\n";

    
// Last inserted sequence
    
$n $Db->LastRowId();
    echo 
"-> <b>Last Row Id:</b> ".$n." <br />\r\n";

    
// Close the connection
    
$Db->Close();
    echo 
"* End";

?> 

 
  Advertise on this site Advertise on this site   Site map Site map   Statistics Statistics   Site tips Site tips   Privacy policy Privacy policy   Contact Contact  

For more information send a message to :
info at phpclasses dot org.
Copyright (c) Icontem 1999-2009 PHP Classes - PHP Class Scripts
  PHP Book Reviews - Reviews of books and other products