Categories > TinyButStrong general >

Dynamic subblock show TBS-error when no subblock empty

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: kle_py
Date: 2010-08-23
Time: 16:58

Dynamic subblock show TBS-error when no subblock empty

Hi,

I am adapting a small application to a modified database, there are some new (empty) fields in the database structure.
In some cases i show listings, where i do a replacement of the displayed value using subblock with dynamic query.
It works fine .. unless my subquery returns an empty array (no data).
When no data are found, a TBS error is shown, for example:
TinyButStrong Error when merging block [sbtvehi] : method clsTbsSql::_Dbs_RsOpen() has failed to open query {SELECT idtipo as id, descripcion as display FROM trp_tipo_vehiculos WHERE idtipo = %p1%}

What would be a clean way to supress such error messages ? - (and simply/silently show an empty string ?)
Thank You.
By: Skrol29
Date: 2010-08-24
Time: 01:12

Re: Dynamic subblock show TBS-error when no subblock empty

Hi,

It seems to be a TBS bug, can you provide a small snippet that reproduce the behavior?
By: kle_py
Date: 2010-08-24
Time: 14:30

Re: Dynamic subblock show TBS-error when no subblock empty

My template is basically:
<tr><td>[blk1.idvehiculo;block=tr;]</td>
<td><span>[sbmarca.display;block=span;p1=[blk1.idmarca]]</span></td>
<td><span>[sbtvehi.display;block=span;p1=[blk1.idtipo]]</span></td>...

The script is basically:
$RecCnt = $TBS->MergeBlock('blk1','tbssql', 'SELECT * from trp_vehiculos') ;    // registers have field "idtipo" empty/NULL !!
$RecCnt = $TBS->MergeBlock('sbmarca', 'tbssql', 'SELECT idmarca as id, descripcion as display FROM trp_marcas WHERE idmarca = %p1%');    // this table is populated !!
$RecCnt = $TBS->MergeBlock('sbtvehi', 'tbssql', 'SELECT idtipo as id, descripcion as display FROM trp_tipo_vehiculos WHERE idtipo = %p1%');    // this table is populated !!
This concept has been prooved to be working for me, it is just the first time i find a problem because of NULL values in the referenced (key-)field for the sub-query.

Apropos. I am using TBS 3.5.3 and TBSsql 2.6 using tbssql_mysqli

p.d. right now i also am testing with the TBS3.0 version from http://www.tinybutstrong.com/download/download.php?file=tbssql.zip&sid=2 (seems to be a beta)
i get some additional messages:
[TbsSql][Trace]: TbsSql version 3.0-beta-2010-07-08/1.03 for MySQL with Improved Extrension (mysqli)
[TbsSql]Database error message: 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

Maybe this info can give a clue ?
greetings,

Klemens
By: Skrol29
Date: 2010-08-25
Time: 01:25

Re: Dynamic subblock show TBS-error when no subblock empty

Hi Klemens,

Thanks for those details. I've reproduce your error message.

It seems to be a bug in TBS subblock process. NULL and empty values are not supported for fields which links the main block and the subblock.
This will be delicate to fix because it overlaps another feature.
Nevertheless, you can workaround this problem by replacing [blk1.idtipo] with [blk1.idtipo;ifempty=0]. Assuming that you have no idtipo=0 in your table [trp_vehiculos].

I've fixed the version problem with TbsSQL 3.0, it should be ok now.

Regards
By: kle_py
Date: 2010-08-25
Time: 14:33

Re: Dynamic subblock show TBS-error when no subblock empty

Thanks skrol,

I think this workaround is a solution which looks "clean enough" for me :) . And it works !
And .. if it will not be too confusing - maybe there could be made a mention or remark for attention in the TBS manual about which parameters may not be null ?
or tune the TBS error messages for these cases ? (to suggest the use of "ifempty" parameter)

Thanks for the help,
greetings,

Klemens