Categories > TinyButStrong general >

Ouch, major pains trying to use ez_sql

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: gavin
Date: 2004-02-09
Time: 02:53

Ouch, major pains trying to use ez_sql

Hi, I decided to spend today looking at TBS. Nice example online but I'm almost ready to give up with the ez_sql integration.

Does anyone have a small working snippet of a template and php file? thanks...
By: Pirjo Posio
Date: 2004-02-09
Time: 08:07

Re: Ouch, major pains trying to use ez_sql

Hello gavin,

This ought to help your pain:
php:
<?php
include_once ('ez_sql.php');
$db = new db("user", "password", "database", "localhost");
include_once ('tbs_class.php');

$TBS = new clsTinyButStrong ;
$TBS->LoadTemplate('tbs_us_examples_datamysql.htm') ;
$query = "SELECT res_name, res_score, res_date FROM t_tbs_exemples ORDER BY res_name";
$TBS->MergeBlock("blk1",$db,$query);

$TBS->Show() ;

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
}
?>

And the template used here is the normal TBS example template for MySQL, which you can find on TBS Example page.

- Pirjo
By: gavin
Date: 2004-02-09
Time: 12:39

Re: Ouch, major pains trying to use ez_sql

Thank you very much! you've also helped me with an ealier post you made:

If you use the ARRAY_A modifier for ez_sql, you can pass the object directly to TBS and treat it as an array type2.

My new question is, what is the advantage of using the custom functions over the method mentioned above?

Thanks again!

By: Pirjo Posio
Date: 2004-02-09
Time: 16:14

Re: Ouch, major pains trying to use ez_sql

Hi again, Gavin!

You may of course use the reading system that suits you best,
since you anyway have both TBS and EzSQL classes present.
In my tests with TBS 1.92 and EzSQL 1.25 the TBS custom functions was quicker than reading with EzSQL and using TBS arrays, to my surprise. You should probably make your own tests.
- Pirjo