|
|
| Skrol29, 2007-03-02 | TbsSQL 2.0 |
| - | %n% | the argument will be protected against Sql Injection. |
| - | @n@ | the argument will be protected against Sql Injection and delimited as a string value with the relevant format for the database. |
| - | #n# | the argument will be converted as a date value without time with the relevant format for the database. |
| - | ~n~ | the argument will be converted as a date and time value with the relevant format for the database. |
| $Db = new clsTbsSQL($srv='',$uid='',$pwd='',$db='',$drv=''); | Instantiates the class. Giving connection information is optional. |
| $Db->Connect($srv,$uid,$pwd,$db,$drv='') or $Db->Connect('glob_var'); |
Open a connection to the database. Syntax 1 example: $Db->Connect('localhost','root','xxx','db_prod');
Syntax 2 example:The argument $drv is needed only for some Dabase Systems. $glob_var = array('srv'=>'localhost','uid'=>'root','pwd'=>'xxx','db'=>'db_prod');
$Db->Connect('glob_var'); 'glob_var' must be the name of a global variable beeing a PHP array with the keys described above. The global variable is destroyed just after the connection. Versioning: syntax2 is available since TbsSQL version 2.0
Note: 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 ->Id. (example: $Db->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. |
| $Db->Close() | Close the current connection to the database. |
| $Db->Execute($sql,...*...) | Execute the Sql statement. |
| $Db->GetVal($sql,...*...) | Returns the value of the first column in the first record of the query. If no record is returned by the query, then the function returns False. |
| $Db->GetRow($sql,...*...) | Returns an associative PHP array which is the first record returned by the query. |
| $Db->GetRows($sql,...*...) | Returns a PHP array of all records returned by the query. |
| $Db->GetList($sql,...*...) | 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. Example: $Db->GetList('SELECT id,name FROM t_people'); will return something like: array(1=>'Peter', 2=>'Dave', 3=>'Jane' ,...) |
| $Db->GetSql($sql,...*...) | Returns the SQL statement with merged arguments. |
| $Db->LastRowId() | Returns the value of the identifier generated by the last INSERT query of your connection. |
| $Db->AffectedRows() | Returns the number of rows affected by the last UPDATE or DELETE query of your connection. |
| $Db->Id | (read/write) The resource Id of your connection. |
| $Db->Mode | (read/write) default value is 1. 0: silent mode, no database error message is displayed. 1: normal mode, the database error message is displayed when an error occurs. 2: debug mode, the full SQL statement is also recalled when an error occurs. 3: trace mode, all queries are displayed. |
| ...*... means a variable number of arguments that will be merged in the SQL statement. | |
| $Db->Row1($sql,...*...) | Same as $Db->GetRow() |
| $Db->Rows($sql,...*...) | Same as $Db->GetRows() |
| $Db->Value($default,$sql,...*...) | Same as $Db->GetVal() but with a default value. |