views:

19

answers:

2

Hello! I have a PHP web app that generates a somewhat complex report from our database. The resulting data structure to populate the report is a big ol' array, and it's heavily nested, and it's kind of a pain to dig into to find just one thing.

Ideally I'd like to have some kind of data structure that I can just query, like a database. Something like "get overall_score from X where Y = Z".

One thought that occurs to me is that I could just use temp tables and query those instead of using the array. But temp tables die after the session; I'd like something that I could keep alive a little longer.

+2  A: 

You want views.

Sjoerd
It could be used for convenience, but keep in mind that as MySQL doesn't support materialized views, performance-wise it's not that much better.
Wrikken
IIRC, views wouldn't work, because the query has SUMs for arbitrary date ranges, and I couldn't pass variables to views. In other words, the date range for the SUM was hard-coded into the view. ( I'm trying to upgrade some old code BTW)
+2  A: 

If you want a temporary database you can create/drop in, delete fully at any time, and is just for convenience in retrieval, I'd load it in an SQLite db. Keep the DB file around as long or as short as you like, share it with other processes, etc.

Wrikken