By: Col
Date: 2009-02-24
Time: 02:08
|
Support columns with spaced namesI have dynamic columns with spaced names. Since the space character is a separator in TBS how do I get it to treat the space as a literal?
This thread (http://tinybutstrong.com/forum.php?msg_id=6574#msg_6574) says it's been available since version 3.2.0 but I can't find any details in the manual or change log. Thanks for any advice. Col |
||||
By: Skrol29
Date: 2009-02-24
Time: 23:34
|
Re: Support columns with spaced namesHi Col,
Column names with spaces could be supported by TBS, but they aren't yet. It's only 2 lines of code to change, but I have not committed to do so. Because, in fact, you can always avoid spaces in column names by using an alias (except if you are calling a stored procedure). |
||||
By: Col
Date: 2009-02-25
Time: 01:31
|
Re: Support columns with spaced namesUnfortunately aliases doesn't work as this array isn't coming straight from a database.
So unfortunately the key block (months) needs to maintain the sequence and therefore must be numbered rather than using something like Sep_08 as the key. Since spaced keys hasn't been implemented I guess this problem is quite unique. I see two possible solutions: 1) If there is some way to edit the format of the key prior to Show(). So the values of the column block could be Sep_08 but on display the underscore is removed. Possible via the onformat feature? (I look into it.) 2) Change the array above so the key of the data above is not a string (Sep 08) but an integer which matches the integer value of the column block. Do-able but not as simple as using a string key. |
||||
By: Skrol29
Date: 2009-02-25
Time: 01:38
|
Re: Support columns with spaced namesHi,
You maybe can perform your (1) by doing a str_replace() on $TBS->Source. But when you say the "array isn't coming straight from a database", I guess you mean that the array structure cannot be modified. That would be my first direction. |
||||
By: Col
Date: 2009-02-25
Time: 01:57
|
Re: Support columns with spaced namesActually the structure can be changed and I'm open to suggestions.
Sorry. "array isn't coming straight from a database" isn't quite correct. It is not being extracted in a single request. The data comes from about 3 tables which, as a single request, was too time consuming. Instead I pull an array from 1 of the tables and reference against it. Also I need to do the percentage calculation which is not coming from the database query. |
||||
By: TomH
Date: 2009-02-26
Time: 06:04
|
Re: Support columns with spaced namesA possibility to get the field names with spaces from MySQL is to use the DESCRIBE query.
Here's a table struct
Using the DESCRIBE
html look like
Maybe a help, TomH |
||||
By: Anonymous
Date: 2009-02-26
Time: 06:39
|
Re: Support columns with spaced namesThanks for the reply and the thoughts Tom.
The problem is that I can't then use those field names as keys to an array referenced by TBS. TBS breaks the field name on the space and says the 'Presidents' or 'Company' is not a valid key in the array. I decided to go with my option 2 above which was a little clunky but not too bad. Using my example from the first post I had a column block like so:
Then in my script I flipped it:
Then, during the creation of $arr (as per original post) instead of keys of the ?_happening arrays I used:
Then my html code looks like this:
|
||||
By: Col
Date: 2009-02-26
Time: 06:40
|
Re: Support columns with spaced namesOops, last post was by me.
|
||||
By: TomH
Date: 2009-02-26
Time: 07:27
|
Re: Support columns with spaced namesYes, no matter it is a little bit clunky ;)
I was using
to access / rename the fields. |