<?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";
 
 
?> 
 
 |