I actually started on a report class yesterday, and I have a few questions,
but first some details:

- Reports will be on user orders (ticket reservations).
- Need to be able to build a large variety of reports based on existing data
 + Orders by a specific user
 + Orders for a specific product (event)
 + Orders by a user sub-group (organization)
 + Orders by a user super-group (school district)
- Reports need data from a primary table (orders) and several secondary
tables (users, order_lineitems, etc.)

Now, I started to approach this with a class that builds an HTML table with
the data as the end product, based upon the parameters I supply.

There shall be a table_header property which will be an array of column
names, a rows property which will be a bi-dimensional array which will
contain the data for each row.

I want to have methods like the following:


$Report->createNew('orders', 35); // STARTS AN ORDER USING `orders` TABLE -
$Report->addColumn('contact'); // USERNAME - `users` TABLE
$Report->addColumn('phone'); // USER'S PHONE NUMBER - `users` TABLE
$Report->addColumn('quantity'); // TICKETS REQUESTED - `order_lineitems`

$report = serialize($Report);

$success = mysql_query('INSERT INTO `reports` (`data`) VALUES (\'' . $report
. '\') ;');

if ($success) { $Notify->addtoQ('Report succesfully saved.', 'confirm'); }
else { $Notify->addtoQ('There was en error saving the report.', 'error'); }


I was having a tough time wrapping my head around how to make the report
class less specific and more flexible. For example, I have the user's
user_id already stored in the `orders` table (of course, foreign key), but I
want to display their username (or firstname, lastname pair), which would
require another call to the `users` table, so I had a $queries property,
which would be an array of queries to execute, but then I couldn't figure
out how to handle each one, because each is handled uniquely.

So, I have to be less general, and more specific. Call what I want by
nickname, ie. $Report->addColumn('userRealName'), and have a switch
statement within the addColumn() method to check for nicknames. Whew! That
sounds awful!

And how do I handle each result in the queries array? Should I create an
associate array (ie. 'username' => 'SELECT `username` FROM `users`....',
'school' => 'SELECT `name` FROM `organization`... ') and again, have a
switch statement to determine how to handle the database result arrays?

Can anyone point me in the right direction? Should I just get down and dirty
and write a focused class (or even procedural?) for different types of
reports that I anticipate needing?

This is a tough one! Thanks!

On Wed, Jan 27, 2010 at 4:32 AM, Ashley Sheridan

> On Tue, 2010-01-26 at 18:54 +0100, PEPITOVADECURT wrote:
> > Exists any reports generator that exports directly to html/php?
> >
> >
> What do you want to generate reports on? I would assume this would be
> some sort of data from a database, and that you're looking for a
> PHP-based reporting tool that can output as HTML for viewing your
> reports in a web browser?
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk

Reply via email to