Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Php array
Polly
Hi all,
i have a arry in our Database wich stores formula's. Now i want to read this array and show the formulla in our report. But i don't no how to start.
Our databse looks like:
Id__Formulaname____________________Type________Arry
47__Oil change savings_____________2___________a:3:{i:0;i:48;i:1;s:1:"*";i:2;i:49;}
48__Cost savings per oil change____2___________ a:7:{i:0;i:50;i:1;s:1:"+";i:2;i:52;i:3;s:1:"+";i:4;i:53;i:5;s:1:"+";i:6;i:51;}
49__Number of oil changes per year_1___________NULL
50__Oil price______________________1___________NULL
51__Change labour cost_____________1___________NULL
52__Clean up supplies______________1___________NULL
53__Oil disposal fee_______________1___________NULL
The report must show:
Oil change savings = Cost savings per oil change * Number of oil changes per year
___Cost savings per oil change = Oil price + Clean up supplies + Oil disposal fee + Change labour cost
______Oil price
______Clean up supplies
______Oil disposal
______Change labour cost
___Number of oil changes per year
I hope someone can help me with this.
Find more posts tagged with
Comments
mwilliams
Hi Polly,
Do you have a formula to decode your arry? You'll probably have to put a hidden text box that's bound to your dataSet before the table in your report so that you can set some variables in your dataSet script and recall them in your table to display what you're wanting. If you can explain more about how to decode your arry, I can probably put together an example of what I mean.
Polly
Hi Michael,
To decode the array:
a:3:{i:0;i:48;i:1;s:1:"*";i:2;i:49;}
a:3 = 3 indexes
i:0 = first index
i:48 = Id (id for formulaname)
i:1 = Second index
s:1 = String of 1 position value *
i:2 = Third index
i:49 = Id (id for formulaname)
The type 1 in the database means: a word wich does not has to be calculated
Type 2: must be calculated
Oh one more thing i forgot, i only need the text before the = in my report. The text afther the = is olso stored in the database.
mwilliams
Ok. So you don't need to decode your formula, you already have that part in your database? If so, can you show what that looks like in your database? I'm just looking for all of your info so I can suggest the best way. You're just looking for the way to display different "levels". Is this correct? Let me know. Thanks.
Polly
Thats correct! The part afther the "=" is stored in the database as a string. So i'm just just looking for the way to display different "levels". In the right order.
mwilliams
So, your database is actually something like:
ID | Formula Name | Arry | String Formula?
Let me know. This is important to the way I'm thinking to do this.
Polly
Thats correct!
Id__Formulaname____________________Type________Arry__________________________________Formula string
47__Oil change savings_____________2___________a:3:{i:0;i:48;i:1;s:1:"*";i:2;i:49;}__Cost savings per oil change * Number of oil changes per year
And thank you for all the effort you are putting in to this!
mwilliams
Polly,
Getting the levels correct will most likely involve a lot of scripting and could take some time. Especially with this data setup. I'm still working on it though. Is there a max number of levels that the table might go out to? Or is that unknown?
Polly
Michael,
There is no max number of levels. Our Database guru told me there is a table for this in our databse, see below.
id_____formula_id____parentformula___Status
1______47____________Null____________Root
2______48____________47______________Active
3______49____________47______________Active
4______50____________48______________Active
5______51____________48______________Active
6______52____________48______________Active
7______53____________48______________Active
If it is easier for you i can make a dump of our test database and sent it to you.
mwilliams
I'm asking around to see if anyone knows an easier solution, but most likely, you'll have to run through the data once and create computed columns and set variables to use when you pass through the data a second time making a HTML table where you take care of the leveling and order. That way would get pretty messy, I think, so I'm seeing if anyone has any better ideas.
Note: It doesn't look like anyone else knows of an easy way to do this, so implementing something like the above might be your best bet.
mwilliams
This would also be something that would be great to add as an enhancement request. I've seen enough people asking about hierarchical tables that it would be a worthwhile feature. You can do so at
http://www.birt-exchange.org/org/resources/bug-reporting/
Polly
Thnx Michael for asking.
i will fill in the bug report.
mwilliams
Perfect. If you can post the enhancement request info in here for others to vote on the enhancement and for future reference, that'd be great. If you come up with something working smoothly on the workaround idea I gave you, the devShare would be a good spot to put it so that others can see what you did too.