Categories > TinyButStrong general >

Split SQL request into many parts with conditions

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Jorge
Date: 2004-01-04
Time: 05:57

Split SQL request into many parts with conditions

Hi,

I have more time and consider to implement TBS into a Website I'm working on now.

TBS works fine (at least when I have examples from your help file)
By the way, I'm trying to split my SQL queries into more than one line and intreduce conditions

I would like to know how could I do something like:
-of course this code doesn't work!! it's here only for help perposes..:) -

$TBS->MergeBlock("blk1",$cnx_id,"select id, name from table") ;
   
if ($id){ //value passed from previous page
$TBS->MergeBlock("blk1",$cnx_id," where id='".$id."'");
}

What's the best way to implement this condition with TBS?

Thanks

Jorge
By: Jorge
Date: 2004-01-04
Time: 05:59

Re: Split SQL request into many parts with conditions

J'ai juste oublié de vous souhaiter une bonne année!!

et que TBS devienne un moteur de templates de référence...

Happy new Year!
By: Jorge
Date: 2004-01-04
Time: 06:11

Re: Split SQL request into many parts with conditions

I need to sleep...found a so simple solution
(was reading to much your examples, and solution was already into php concept)

Solution (for other beginners, or people needing to sleep like me!)

$query = "select id, name from table";

if ($id){                                  //value passed from previous page

$query .= " where id='".$id."'";  // note the '.' after 'query'
}

$TBS->MergeBlock("blk1",$cnx_id,$query) ;