Categories > TinyButStrong general >

about Dynamic queries / sub-blocks

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: dowdot
Date: 2005-06-28
Time: 15:06

about Dynamic queries / sub-blocks

i want use Dynamic queries / sub-blocks
but always have error

TinyButStrong Error (MergeBlock [paper]): MySql error message when opening the query: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '%p1%' at line 1

////////////////////////////////////////////////////////////////////////////
my template code
/////////////////////////////////////////////////////////////////////////////
       <table width="100%"  border="0" cellpadding="2" cellspacing="1" bgcolor="#999999">
         <tr bgcolor="#FFFFFF">
                    <td class="style20"><center>[paper.#]</center></td>
                    <td class="style20"><center>[user.name]</center></td>
                    <td class="style20"><center>[paper.title;block=tr;p2=[user.uid]]</center></td>
    </tr>
</table>
/////////////////////////////////////////////////////////////////////////////



my php code
////////////////////////////////////////////////////////////////////////////

$sql1="SELECT * FROM user";
$TBS->MergeBlock('user',$link,$sql1);

$TBS->MergeBlock('paper',$link,'SELECT * FROM paper WHERE uid=%p1% ');


$TBS->Show() ;
////////////////////////////////////////////////////////////////////////////
By: Skrol29
Date: 2005-06-28
Time: 15:31

Re: about Dynamic queries / sub-blocks

Hi,

That's a problem which should be arranged in next version.
When the main block return no record, then there is no sub-block definition left in the template. Then the second MergeBlock() for sub-template brings an error because TBS doesn't know the query is dynamic.

Here is what I suggest:
$nbr = $TBS->MergeBlock('user',$link,$sql1);
if ($nbr>0) $TBS->MergeBlock('paper',$link,'SELECT * FROM paper WHERE uid=%p1% ');

And this should run ok.
By: Eliseu
Date: 2005-07-19
Time: 18:40

Re: about Dynamic queries / sub-blocks

I have still the problem like dowdot.

here is my html:

[blk_insc_cap;block=begin]
[sub_blk_insc_cap;block=begin]

Name: [blk_insc_cap.name]
Location: [sub_blk_insc_cap.name;p1=[blk_insc_cap.capitulo_id]]

[blk_insc_cap;block=end]
[sub_blk_insc_cap;block=end]

Here is my php:

$TBS->MergeBlock('blk_insc_cap',$conn,'select * from inscrito');
$TBS->MergeBlock('sub_blk_insc_cap',$conn,'select nome from capitulo_loja where (id=%p1%) ');

and the same error :
(MergeBlock [sub_blk_insc_cap]): MySql error message when opening the query: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '%p1%)' at line 1

But the first block works! The "name" field is OK. Just the second do this.
By: Skrol29
Date: 2005-07-19
Time: 23:19

Re: about Dynamic queries / sub-blocks

Hi Eliseu,

Parameter (p1=...) should be in the same tag as (block=...) because it's a parameter of block.
By: Eliseu
Date: 2005-07-20
Time: 03:22

Re: about Dynamic queries / sub-blocks

Tnx, it worked..