Categories > TinyButStrong general >

ezsql v2.0 "TBS database function" hack

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Tom
Date: 2006-01-16
Time: 22:23

ezsql v2.0 "TBS database function" hack

Hi Skrol29

There has been a new release of ezsql (now v2.0)

In upgrading to the new ezsql - I found that` I had to hack the TBS
database function to use with ezsql

Here's my hack -- it should be tested and _you_ might see more to do if you look at the new ezsql version 2

/*
ezSQL functions for TinyButStrong Template Engine
Version 1.00, 2004-09-22, Skrol29
http://www.tinybutstrong.com

Example:
    $TBS->MergeBlock('blk1',$db,'SELECT * FROM t_examples');

Note:
    $db is a global variable set by the ezSQL library.
*/
/*
function tbsdb_db_open(&$db,&$query) {
    $db->get_results($query) ;
     return $db ;
}
}
function tbsdb_db_fetch(&$db,$num) {
    if ($num<=$db->num_rows) {
        return $db->get_row(null,ARRAY_A,$num-1) ;
    } else {
    return False ;
    }
}
function tbsdb_db_close(&$db) {
    // not needed
}
*/
// === TJH === Changed to match up with zSQL version 2.0 ===
function tbsdb_ezsql_mysql_open(&$db,&$query) {
    $db->get_results($query) ;
     return $db ;
}
function tbsdb_ezsql_mysql_fetch(&$db,$num) {
    if ($num<=$db->num_rows) {
        return $db->get_row(null,ARRAY_A,$num-1) ;
    } else {
    return False ;
    }
}
function tbsdb_ezsql_mysql_close(&$db) {
    // not needed
}

HTH,
Tom
By: Skrol29
Date: 2006-01-17
Time: 14:22

Re: ezsql v2.0 "TBS database function" hack

Thanks Tom.
I will try you cod and update the function to download.
By: Skrol29
Date: 2006-01-19
Time: 18:30

Re: ezsql v2.0 "TBS database function" hack

I've updated the functions, but a bit differently than you.
Now those functions are available for any ezSQL data type (MySQL, Postgre, ...)

Thanks again,
By: ashorlivs
Date: 2006-01-20
Time: 01:00

Re: ezsql v2.0 "TBS database function" hack

Hi,
how to get the new function ? I still see the "old" one (september) in the download > db section.

Thanks !
Ashor
By: Skrol29
Date: 2006-01-20
Time: 02:04

Re: ezsql v2.0 "TBS database function" hack

I confirme it is updated. I downloaded it rigth just now.
Did you choose ezSQL in the database list ?
By: ashorlivs
Date: 2006-01-20
Time: 12:05

Re: ezsql v2.0 "TBS database function" hack

It's ok now!
Thanks,
Ashor
By: Tom
Date: 2006-01-22
Time: 14:37

Re: ezsql v2.0 "TBS database function" hack

Skrol
That's great -- works a treat.

Thanks for taking the time to check the ezSQL changes and doing it proper.

[var.ThanksForTBS]