Location: PHPKode > scripts > TbsSQL > tbssql_help.html
<?php
mb_http_input("iso-8859-1");
mb_http_output("iso-8859-1");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>TbsSQL - documentation</title>
<style type="text/css">
<!--
body, td, th {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: 11px;
}
.sql {
	font-family: "Courier New", Courier, mono;
	color: #006600;
}
.decal {
	margin-left: 20px;
}
h1 {
	font-size: 18px;
	font-weight: bold;
}
h2 {
	font-size: 13px;
	font-weight: bold;
}
h3 {
	text-decoration: underline;
	font-weight: normal;
	font-size: 12px;
}
.versioning {
	background-color: #EAEAEA;
}
.split {
	border-bottom-width: 1px;
	border-bottom-style: dotted;
	border-bottom-color: #069;
}
.split0 {
	border-top-width: 1px;
	border-top-style: dotted;
	border-top-color: #069;
}
.optional {
	color: #666;
	font-style: italic;
}
-->
</style>
</head>

<body>
<table width="100%" border="0" cellspacing="0" cellpadding="3">
  <tr>
    <td width="200"><a href="http://www.tinybutstrong.com">Skrol29</a>, 2010-10-22 </td>
    <td><h1 align="center">TbsSQL 3.1</h1></td>
    <td width="200">&nbsp;</td>
  </tr>
</table>
<hr />
<h2 id="placeholders2">Summary</h2>
<div class="decal">
  <ol>
    <li><a href="#presentation">Presentation</a></li>
    <li><a href="#placeholders">SQL statements with placeholders</a></li>
    <li><a href="#synopsis">Synopsis</a>
      <ol>
        <li><a href="#connecting">Connecting to the database</a></li>
        <li><a href="#options">Options and information</a></li>
        <li><a href="#sql">Working with SQL</a></li>
        <li><a href="#cache">Using the cache feature</a></li>
        <li><a href="#tbs">Working with TinyButStrong template engine</a>    </li>
      </ol>
    </li>
    <li><a href="#deprecated">Deprecated</a></li>
    <li><a href="#license">License</a></li>
    <li><a href="#changelog">Change log</a></li>
  </ol>
  <div class="decal"></div>
</div>
<hr />
<h2><a name="presentation" id="presentation" />1. Presentation</h2>
<div class="decal"> The goal of TbsSQL is to reduce the code when working with SQL through PHP. It is called a SQL abstraction tool.<br />
  <br />
  The TbsSQL 
  trumps are:<div class="decal">
  - simple to use, easy to install (only one class), few methods an properties<br />
  - placeholders for merging values in one shot<br />
- return data as array, standard objects, specific class objects or clone objects<br />
- a simple cache feature with strict SQL identification (unlike ezSQL)<br />
- a trace mode, and a debug console<br />
- recognized by the TinyButStrong template engine
<br />
  </div>
<br />
  TbsSQL is available for the following databases:<br />
  <div class="decal">- MySQL<br />
    - MySQLi<br />
    - SQL-Server (via Ms ODBC or UnixODBC)<br />
    - PostgreSQL (version 7.2 or higher) <br />
    - ODBC Generic (<span class="versioning">available since TbsSQL version 2.6</span>)<br />
  - Oracle (<span class="versioning">available since TbsSQL version 3.1</span>) </div>
</div>
<h2><a name="placeholders" id="placeholders" />2. SQL statements with placeholders</h2>
<div class="decal"> The main asset of TbsSQL is that SQL statement  writing  is really simplified because you can use placeholders in the SQL for placing item data coming from PHP. And item data are always protected against <a href="http://en.wikipedia.org/wiki/Sql_injection">SQL injection</a>.<br />
  <br />
  <u>Example:</u> <br />
  <div class="decal"><span class="sql">$id = 29;<br />
    $name = &quot;boby&quot;; <br />
    $Db-&gt;Execute('UPDATE table1 SET name=@2@ WHERE (id=%1%)', $id, $name);</span><br />
    In this example, the final SQL statement sent to the database will be: <span class="sql">UPDATE table1 SET name='boby' WHERE (id=29)</span></div>
  <br />
  TbsSQL supports the following jokers  in your SQL statements:<br />
  &nbsp;&nbsp;&nbsp;&nbsp;(the following jokers are for argument number 1, but it is the same thing for argument number 2, 3, 4, ...)<br />
  <table width="100%" border="0" cellspacing="0" cellpadding="3">
    <tr>
      <td width="10">-</td>
      <td width="40">%1%</td>
      <td>The joker will be replaced with 1st argument protected against SQL injection.</td>
    </tr>
    <tr>
      <td>-</td>
      <td>@1@ </td>
      <td>The joker will be replaced with 1st argument protected against SQL injection and delimited using the relevant string delimiter of the  database.</td>
    </tr>
    <tr>
      <td>-</td>
      <td>#1#</td>
      <td>The joker will be replaced with 1st argument converted into a date value (without time part) using the relevant date format of the database.</td>
    </tr>
    <tr>
      <td>-</td>
      <td>~1~ </td>
      <td>The joker will be replaced with 1st argument converted into a date-time value using the relevant date-time format of the database.</td>
    </tr>
  </table>
  <br />
  <u>Managing NULL values:</u><br />
  You can also use jokers %[1]% , @[1]@ , 
  #[1]# and ~[1]~ to replace the value by the SQL keyword 'NULL' when the value to merge is the PHP value {false} or {null}. Please note that empty string {''} will not be replaced with the SQL keyword 'NULL'.<br />
  Example:<br />
  <div class="decal"><span class="sql">$id = 29;<br />
    $date = false; <br />
    $Db-&gt;Execute('UPDATE table1 SET fd=[#2#] WHERE (id=%1%)', $id, $date);</span><br />
    In this example, the SQL statement sent to the database will be: <span class="sql">UPDATE table1 SET fd=NULL WHERE (id=29)</span></div>
  <div class="versioning">Versioning: Jokers for nullable values are supported since TbsSQL version 2.5.</div>
</div>
<h2><a name="synopsis" id="synopsis" />3. Synopsis</h2>
<div class="decal">
  <h3><a name="connecting" id="connecting" /></a>3.1 Connecting to the database</h3>
  <table width="100%" border="0" cellpadding="4" cellspacing="0" class="decal">
    <tr id="clstbssql">
      <td width="260" valign="top" class="split0 split">$Db = new <strong>clsTbsSQL</strong>($srv='',$uid='',$pwd='',$db='',$drv='',$mode=TBSSQL_NORMAL); </td>
      <td valign="top" class="split0 split">Instantiates the class. 
        Giving connection information is optional. <br />
        <span class="versioning">Versioning: optional argument $mode is supported since TbsSQL version 2.6.</span></td>
    </tr>
    <tr id="connect">
      <td valign="top" class="split">$Db-&gt;<strong>Connect</strong>($srv,$uid,$pwd,$db,$drv='',$mode=TBSSQL_NORMAL)<br />
        &nbsp;&nbsp;or<br />
        $Db-&gt;<strong>Connect</strong>('glob_var');<br />
        <br />
        <u>Arguments:</u><br />
        $srv: server (or connection string for some database type)<br />
        $uid: user id<br />
        $db: database name<br />
        $drv: driver (optional, needed for some database type)<br />
        $mode: TbsSQL warning mode (see property Mode)</td>
      <td valign="top" class="split">Open a connection to the database.<br />
        Syntax 1 example:<br />
        <div class="decal"><span class="sql">$Db-&gt;Connect('localhost','root','xxx','db_prod');</span><br />
          The argument $drv is needed only for some Database Systems.</div>
        Syntax 2 example:<br />
        <div class="decal"><span class="sql">$glob_var = array('srv'=&gt;'localhost','uid'=&gt;'root','pwd'=&gt;'xxx','db'=&gt;'db_prod');<br />
          $Db-&gt;Connect('glob_var');</span><br />
          'glob_var' must be the name of a global variable containing a PHP array with the keys described above.<br />
          The global variable is <strong>destroyed</strong> just after the connection. </div>
        <div class="versioning">Versioning: syntax2 is available since TbsSQL version 2.0. Optional argument $mode is supported since TbsSQL version 2.6.<br />
        </div>
        <u>Note:</u> You don't need to call this method if your connection has already been opened before. In this case, you just have to assign the connection id to property -&gt;Id. (example: $Db-&gt;Id = $mycn). You don't have to do this assignation when PHP can work automatically with the last opened connection. This is the case for MySQL for example.<br />
        <u>ODBC:</u> (and SQL server with ODBC)<br />
        Argument $srv can be a server name, or a connection string. You can define a DSN (Data Source Name) using the connection string: 'DSN=my_dsn'.<br />
        Examples:<br />
        <span class="sql">$drv	= 'my_server';<br />
        $drv = 'DSN=my_dsn'<br />
        $drv = 'DRIVER={SQL Server};SERVER=my_server'<br />
        $drv = 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\mydatabase.mdb;'</span></td>
    </tr>
    <tr id="close">
      <td valign="top" class="split">$Db-&gt;<strong>Close</strong>()</td>
      <td valign="top" class="split">Close the current connection to the database.</td>
    </tr>
    <tr id="id">
      <td valign="top" class="split">$Db-&gt;<strong>Id</strong></td>
      <td valign="top" class="split">(read/write) The resource  Id of the database connection. It is automatically updated by the methods Connect() and Close().<br />        
      This property can be useful:<br />
      1) 
When you want to use TbsSQL with a connection which is already opened. Thus you just have to set $Db-&gt;Id = $MyCurrentConnection instead of using method Connect().<br />
2) When you'd like to retrieve the connection id for an operation that TbsSQL cannot do. Example: $x = mysql_thread_id($Db-&gt;Id);<br /></td>
    </tr>
  </table>
  <h3><a name="options" id="connecting2" /></a></a>3.2 Options and information</h3>
  <table width="100%" border="0" cellpadding="4" cellspacing="0" class="decal">
    <tr id="mode2">
      <td width="260" valign="top" class="split"><a name="mode" id="mode2" /></a>$Db-&gt;<strong>Mode</strong></td>
      <td valign="top" class="split">(read/write) default value is TBSSQL_NORMAL.<br />
        You can choose a value among the following: <br />
        <table border="0" cellspacing="2" cellpadding="0">
          <tr>
            <td width="10" valign="top">&bull;</td>
            <td width="120" valign="top" class="sql">TBSSQL_SILENT</td>
            <td width="10">&nbsp;</td>
            <td>TbsSQL never display messages. </td>
          </tr>
          <tr>
            <td valign="top">&bull;</td>
            <td width="120" valign="top" class="sql">TBSSQL_NORMAL</td>
            <td>&nbsp;</td>
            <td>The database error message is displayed only when an error occurs.</td>
          </tr>
          <tr>
            <td valign="top">&bull;</td>
            <td width="120" valign="top" class="sql">TBSSQL_DEBUG</td>
            <td>&nbsp;</td>
            <td>Both database error message and the full SQL statement are recalled but only when an error occurs.</td>
          </tr>
          <tr>
            <td valign="top">&bull;</td>
            <td width="120" valign="top" class="sql">TBSSQL_TRACE</td>
            <td>&nbsp;</td>
            <td>All queries  are displayed.</td>
          </tr>
        </table>
        You can also add the following values:
        <table border="0" cellspacing="2" cellpadding="0">
          <tr>
            <td width="10" valign="top">&bull;</td>
            <td width="120" valign="top" class="sql">TBSSQL_CONSOLE</td>
            <td width="10">&nbsp;</td>
            <td>TbsSQL messages are displayed in a Html popup window.</td>
          </tr>
          <tr>
            <td valign="top">&bull;</td>
            <td width="120" valign="top" class="sql">TBSSQL_GRID</td>
            <td>&nbsp;</td>
            <td>Full data results are displayed in an Html grid.</td>
          </tr>
        </table>
        <br />
        <div class="decal"><u>Example:</u> <span class="sql">$Db-&gt;Mode = TBSSQL_TRACE + TBSSQL_GRID + TBSSQL_CONSOLE;</span></div>
        <br />
        <div class="versioning">Versioning:  constants TBSSQL_* are supported since TbsSQL version 2.5<br />
          TBSSQL_CONSOLE and 
          TBSSQL_GRID are supported since version 3.0<br />
        </div></td>
    </tr>
    <tr id="defaultrowtype2">
      <td valign="top" class="split">$Db-&gt;<strong>DefaultRowType</strong></td>
      <td valign="top" class="split">(read/write) The type of row returned by default by methods GetRow() and GetRows().<br />
        The default value is TBSSQL_ARRAY.<br />
        <table border="0" cellspacing="3" cellpadding="0">
          <tr>
            <td colspan="2"><u>Value</u></td>
            <td width="10">&nbsp;</td>
            <td><u>Description</u></td>
          </tr>
          <tr>
            <td width="10">&bull;</td>
            <td class="sql">TBSSQL_ARRAY</td>
            <td>&nbsp;</td>
            <td>each returned row is an associative PHP array</td>
          </tr>
          <tr>
            <td>&bull;</td>
            <td class="sql">TBSSQL_OBJECT</td>
            <td>&nbsp;</td>
            <td>each returned row is a primary object (class=stdClass)</td>
          </tr>
          <tr>
            <td>&bull;</td>
            <td>a string which is a class name</td>
            <td>&nbsp;</td>
            <td>each returned row is a new instance of the corresponding class</td>
          </tr>
          <tr>
            <td>&bull;</td>
            <td>an instance of an object</td>
            <td>&nbsp;</td>
            <td>each returned row is built from a clone of the given object</td>
          </tr>
        </table>
        Please note that methods GetRow() and GetRows() have an optional argument which allow to choose the type of returned row.</td>
    </tr>
    <tr id="defaultrowtype2">
      <td valign="top" class="split">$Db-&gt;<strong>ConfInfo</strong>()</td>
      <td valign="top" class="split">Display information about the current configuration of TbsSQL.
        <div class="versioning">Versioning:  method ConfInfo() is supported since TbsSQL version 3.1.<br />
      </div></td>
    </tr>
  </table>
  <h3><a name="sql" id="sql" /></a>3.3 Working with SQL</h3>
  <table width="100%" border="0" cellpadding="4" cellspacing="0" class="decal">
    <tr id="execute">
      <td width="260" valign="top" class="split split0">$Db-&gt;<strong>Execute</strong>($sql <span class="optional">[,$val1, $val2, ...]</span>)</td>
      <td valign="top" class="split split0">Execute the Sql statement.<br />
        Argument $sql can contain <a href="#placeholders">placeholders</a> for $val1, val2, ...</td>
    </tr>
    <tr id="getval">
      <td valign="top" class="split">$Db-&gt;<strong>GetVal</strong>($sql <span class="optional">[,$val1, $val2, ...]</span>)</td>
      <td valign="top" class="split">Returns the value of the first column in the first record of the query.<br />
        If no record is returned by the query, then the function returns false.<br />
        Argument $sql can contain <a href="#placeholders">placeholders</a> for $val1, val2, ...</td>
    </tr>
    <tr id="getrow">
      <td valign="top" class="split">$Db-&gt;<strong>GetRow</strong>(<span class="optional">[$rowtype,]</span> $sql <span class="optional">[,$val1, $val2, ...]</span>)</td>
      <td valign="top" class="split">Returns the first record returned by the query. Return false in case of no record.<br />
        You can  precise the row type for this query using  argument $rowtype. See  property <a href="#defaultrowtype">DefaultRowType</a> for accepted values. If argument $rowtype is omitted, then the returned row type depends of  property DefaultRowType.<br />
        Argument $sql can contain <a href="#placeholders">placeholders</a> for $val1, val2, ...</td>
    </tr>
    <tr id="getrows">
      <td valign="top" class="split">$Db-&gt;<strong>GetRows</strong>(<span class="optional">[$rowtype,]</span> $sql <span class="optional">[,$val1, $val2, ...]</span>)</td>
      <td valign="top" class="split">Returns all records returned by the query. Return an empty array in case of no record.<br />
        You can  precise the row type for this query using  argument $rowtype. See  property <a href="#defaultrowtype">DefaultRowType</a> for accepted values. If argument $rowtype is omitted, then the returned row type depends of  property DefaultRowType.<br />
        Argument $sql can contain <a href="#placeholders">placeholders</a> for $val1, val2, ...</td>
    </tr>
    <tr id="getlist">
      <td valign="top" class="split">$Db-&gt;<strong>GetList</strong>($sql <span class="optional">[,$val1, $val2, ...]</span>)</td>
      <td valign="top" class="split">Returns a PHP array with first column as keys and second column as values. If only one columns is given by the query then they the values of the array. <br />
        <div class="decal"><u>Example:</u> <span class="sql">$Db-&gt;GetList('SELECT id,name FROM t_people');</span><br />
          will return something like: array(1=&gt;'Peter', 2=&gt;'Dave', 3=&gt;'Jane' ,...)</div>
        Argument $sql can contain <a href="#placeholders">placeholders</a> for $val1, val2, ...</td>
    </tr>
    <tr id="getsql">
      <td valign="top" class="split">$Db-&gt;<strong>GetSql</strong>($sql <span class="optional">[,$val1, $val2, ...]</span>)</td>
      <td valign="top" class="split">Returns the SQL statement with merged arguments.<br />
        Argument $sql can contain <a href="#placeholders">placeholders</a> for $val1, val2, ...</td>
    </tr>
    <tr id="lastrowid">
      <td valign="top" class="split">$Db-&gt;<strong>LastRowId</strong>()</td>
      <td valign="top" class="split">Returns the value of the identifier generated by the last INSERT query of your connection. <br />
        <u>Notes:</u><br />
        - 
        This method is not available for ODBC Generic.<br />
        - For Oracle databases, you must precise the sequence name as the first argument of the method. For example: $x = $Db-&gt;LastRowId('my_seq');</td>
    </tr>
    <tr id="affectedrows">
      <td valign="top" class="split">$Db-&gt;<strong>AffectedRows</strong>()</td>
      <td valign="top" class="split">Returns the number of rows affected  by the last UPDATE or DELETE query of your connection.<br />
        <u>Note:</u> This method is not available for ODBC Generic.</td>
    </tr>
  </table>
  <h3><a name="cache" id="cache" /></a>3.4 Using the cache feature</h3>
  <p class="decal">What is the TbsSQL cache feature? SQL queries results can be saved in cache files in order to save time execution when they are recalled. Cache files are available for a limited duration (timeout) in order to ensure the actualization of the data. <br />
    The TbsSQL cache feature is disabled by default. You can enable it simply by setting a positive value to property $Db-&gt;CacheTimeout.<br />
    Interesting technical notes: <br />
    - 
    TbsSQL cache files cannot be read by users because they are PHP files.<br />
    - 
    The TbsSQL cache feature will never provide data from another SQL query. Other tools, like  ezSQL for example, can <span id="result_box2"><span title="">theoretically</span></span> be wrong when identifying a cache file because they are identified only by a hash value (md5). Hash values are not  unique ids, even if the probability of doubles is very poor.<br />
    - 
    When the cache is enabled, TbsSQL will (by default) automatically get rid of cache files that come from old unused queries.</p>
  <table width="100%" border="0" cellpadding="4" cellspacing="0" class="decal">
    <tr id="cachetimeout">
      <td width="260" valign="top" class="split0 split">$Db-&gt;<strong>CacheTimeout</strong></td>
      <td valign="top" class="split0 split">Defines the cache timeout in minutes for all SQL queries called by methods GetVal(), GetRow(), GetRows() and GetList().        The default value is TBSSQL_DISABLED (or value false for TbsSQL prior to 3.1), which means the cache feature is disabled. Note that method Execute() is not concerned by the cache feature.<br />
        The simplest way to define the timeout is to  use constants:<br />
        <div class="decal">
        TBSSQL_DISABLED  <span class="versioning">(since TbsSQL version 3.1)</span>, this constant is the value false, it makes TbsSQL no neither read or write the cache.<br />
        TBSSQL_ALWAYS <span class="versioning">(since TbsSQL version 3.1)</span>, this constant is the value 0, it forces TbsSQL to always save the cache for queries.</div>
        or combine the following other constants:<br />        <div class="decal">TBSSQL_1WEEK<br />        TBSSQL_1DAY<br />
        TBSSQL_1HOUR<br />        
        TBSSQL_1MINUTE <span class="versioning">(since TbsSQL version 3.1)</span></div>
        Use property TempCacheTimeout to force the cache for<span id="result_box"><span title=""> only one query, whether default cache is enabled or not.</span></span>
        <div class="decal"><u>Example:</u> $Db-&gt;CacheTimeout = TBSSQL_1WEEK + 2 * TBSSQL_1DAY;<br />
        this  does enable the cache for all queries with a cache duration of one week and two days.</div></td>
    </tr>
    <tr id="tempcachetimeout">
      <td valign="top" class="split">$Db-&gt;<strong>TempCacheTimeout</strong></td>
      <td valign="top" class="split">Define the cache timeout in minutes but only for the next query. You can use this property to enable, disable or change change the cache timeout for a only one very query.<br />
        Default value is TBSSQL_DISABLED (or value false for TbsSQL prior to 3.1), which means there is no different  timeout for the next query.
        <div class="decal"><u>Example:</u><br />
          <span class="sql">$Db-&gt;TempCacheTimeout = TBSSQL_1DAY;<br />
          $x = $Db-&gt;GetRows('SELECT id, name FROM table1 ORDER BY id');</span><br />
        </div>
        If the cache is enabled (i.e. CacheTimeout &gt; 0), you can disable the cache only for the next query by setting TempCacheTimeout to TBSSQL_NOCACHE</td>
    </tr>
    <tr id="cacheautoclear">
      <td valign="top" class="split">$Db-&gt;<strong>CacheAutoClear</strong></td>
      <td valign="top" class="split"> When the cache is enabled, TbsSQL can try to delete old cached queries in the cache directory. <br />
        The default value is TBSSQL_1WEEK.</td>
    </tr>
    <tr id="cachedir">
      <td valign="top" class="split">$Db-&gt;<strong>CacheDir</strong></td>
      <td valign="top" class="split"> This property defines the directory where cached queries are stored.<br />
        The default value is '.'.</td>
    </tr>
    <tr id="cachesuffix">
      <td valign="top" class="split">$Db-&gt;<strong>CacheSuffix</strong></td>
      <td valign="top" class="split">Default value is '' (empty string). This property enables you to add a suffix in the cache file names. You do not need it most of the time. It is designed to separate the cached results  for the same SQL queries string, for example when a project may use the same queries in  two different Databases.</td>
    </tr>
    <tr>
      <td valign="top" class="split">$Db-&gt;<strong>CacheTimestamp</strong>($sql)</td>
      <td valign="top" class="split">Returns the timestamp of the cache file corresponding to $sql. Returns <span class="sql">false</span> if the SQL has no cache file.</td>
    </tr>
    <tr>
      <td valign="top" class="split">$Db-&gt;<strong>CacheFileName</strong>($sql)</td>
      <td valign="top" class="split">Returns the file path of the cache file corresponding to $sql. Returns <span class="sql">false</span> if the SQL has no cache file.</td>
    </tr>
    <tr>
      <td valign="top" class="split">$Db-&gt;<strong>CacheDelete</strong>($sql)</td>
      <td valign="top" class="split">Try to delete the cache file corresponding to $sql. Returns <span class="sql">true</span> if succeed, otherwise returns <span class="sql">false</span>.</td>
    </tr>
  </table>
  <h3><a name="tbs" id="tbs" /></a>3.5 Working with TinyButStrong template engine</h3>
  <table width="100%" border="0" cellpadding="4" cellspacing="0" class="decal">
    <tr id="tbskey">
      <td width="260" valign="top" class="split0 split">$Db-&gt;<strong>TbsKey</strong></td>
      <td valign="top" class="split0 split">(read) Return the TinyButStrong key string for the current connection (see chapter Hook above). This property has always a default value which is unique for each new instance.<br />
        Most of the time there is no need know the value of this property,  since you can use the property directly with TBS.<br />
        Example: <span class="sql">$TBS-&gt;MergeBlock('b',$Db-&gt;TbsKey,'SELECT * FROM table1');</span> <br />
        <div class="versioning">Versioning: this property is available since TbsSQL version 2.5<br />
        </div></td>
    </tr>
    <tr id="settbskey">
      <td valign="top" class="split">$Db-&gt;<strong>SetTbsKey</strong>($key)</td>
      <td valign="top" class="split">Change the value of property $Db-&gt;TbsKey. Most of the time, there is no need to use this method because property TbsKey has always a default value which is unique. Use this method only if your application does need a customized key value for the TinyButStrong merging.<br />
        Example:<br />
        <div class="sql decal">$Db-&gt;SetTbsKey('myconnection');<br />
          $TBS-&gt;MergeBlock('b', 'myconnection', 'SELECT * FROM table1');</div>
        <div class="versioning">Versioning: this method is available since TbsSQL version 2.5</div></td>
    </tr>
  </table>
</div>
<h2><a name="deprecated" id="deprecated" />4. Deprecated</h2>
<div class="decal">
  <p>Those methods are deprecated in TbsSQL version 2.x, and unsupported since version 3.x</p>
  <table width="100%" border="0" cellspacing="0" cellpadding="3">
    <tr>
      <td width="260" valign="top">$Db-&gt;Row1($sql,...*...)</td>
      <td valign="top">Same as $Db-&gt;GetRow()</td>
    </tr>
    <tr>
      <td valign="top">$Db-&gt;Rows($sql,...*...)</td>
      <td valign="top">Same as $Db-&gt;GetRows()</td>
    </tr>
    <tr>
      <td valign="top">$Db-&gt;Value($default,$sql,...*...)</td>
      <td valign="top">Same as $Db-&gt;GetVal() but with a default value. </td>
    </tr>
  </table>
</div>
<h2><a name="license" id="license" /></a></a>5. License</h2>
<div class="decal"> TbsSQL is a free and open source. It is published under the LGPL license. </div>
<h2><a name="changelog" id="changelog" />6. Change log</h2>
<div class="decal">
  <p>Version 3.2, 2010-10-21</p>
  <p>- Bug fix: Information of configuration is displayed when a TbsSQL error message occurs.<br />
  </p>
  <p>Version 3.1, 2010-10-11</p>
  <p>- Support Oracle databases.<br />
    - New methode ConfInfo() displays configuration information at any time.<br />
    - Fixed bug: clear and restore the console window when the parent window is actualized.<br />
- Fixed bug: function _SqlDateFrmDb() may causes a PHP error &quot;Notice: Undefined variable: x in ...tbssql_sqlserver_odbc.php on line 461&quot;.<br />
    - Enhanced configuration information displayed in trace mode.<br />
- New constants: TBSSQL_1MINUTE, TBSSQL_DISABLED, TBSSQL_ALWAYS.</p>
  <p>Version 3.0, 2010-08-19</p>
  <p>- New cache feature<br />
    - Can return records as objects (as stdClass instances, or as your own class instances or as clones of any instances)<br />
    - Can return trace in a console, and can trace data in a grid<br />
    - New property Version (is it useful?)<br />
    - More compatibility with PHP 4<br />
    - Can handle dates over the 32bit limits (1970-2038) if PHP =&gt; 5.2 <br />
    - Trace mode now works when TbsSQL is used within TinyButStrong</p>
  <p>Version 2.6, 2009-11-26</p>
  <p>- Argument $Mode has been added to the class instantiation and to method Connect().<br />
    This allows to display error message and trace when the connection is made.<br />
    - Display the connection string in trace mode (Mode=TBSSQL_TRACE)<br />
    - New database support : ODBC (generic), for both Windows and Unix) <br />
    - Support UnixODBC for ODBC Generic and ODBC for SQL Server.<br />
    - Use canonical formats for date and time with ODBC Generic and ODBC for SQL Server.<br />
    - Support ODBC connection string with ODBC and ODBC Generic for SQL Server.<br />
    - Do not use @ with odbc_connect() because some error of connection can make a PHP critical error.<br />
    In this case @ avoid any error and warning messages which are uncomfortable.</p>
  <p>Version 2.5, 2009-09-16</p>
  <p>- New set of jokers that supports NULL values for SQL.<br />
    - constants that can be used for property $Db-&gt;Mode :<br />
    TBSSQL_SILENT<br />
    TBSSQL_NORMAL<br />
    TBSSQL_DEBUG<br />
    TBSSQL_TRACE<br />
    - Bug for TbsSQL with MySQL : each TbsSQL instance was always linked to the <br />
    last MySQL connection. That was because property $Db-&gt;Id was always set to True<br />
    instead of the MySQL connection resource. <br />
    - New property $Db-&gt;TbsKey : enables you to use several instances of TbsSQL with TinyButStrong.<br />
    - New method $Db-&gt;SetTbsKey() : enables you to customize instances of TbsSQL with TinyButStrong.</p>
</div>
<h2 id="placeholders4"></h2>
</body>
</html>
Return current item: TbsSQL