[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Again - Perl: DB.PHP.Cache



Again - directed mainly at Aaron - I dunno who our other Perl coders
are... and this is another Perl thing - so if yur interested catch up with
Aaron.

This is for caching Object structures from the Database into a PHP
definition file since they don't change often enough to warrant a query
every time there's a page load.  Currently every page load is generating 3
or 4 database queris just to determine the structure of the objects... I
find this unnecisary - since after go live, this will happen rarely.

So - as I mentioned to Aaron previously - I'm thinking a perl script to
query the DB and build a file PHP can include would be much better.  This
include will simply define variables that contain object information.

Here is the way I think the variables should be built... and below are the
querys that should work:

$OBJECT_TYPES[0 -?] = Array of valid Object Type ID's

$TYPE_PROPERTIES[ $OBJECT_TYPE[x] ]["Name"] =
$TYPE_PROPERTIES[ $OBJECT_TYPE[x] ]["Desc"] =
$TYPE_PROPERTIES[ $OBJECT_TYPE[x] ]["ValidChildren"] =
$TYPE_PROPERTIES[ $OBJECT_TYPE[x] ]["Class"] = 
$TYPE_PROPERTIES[ $OBJECT_TYPE[x] ]["DefaultActionID"] = 
$TYPE_PROPERTIES[ $OBJECT_TYPE[x] ]["ExtensionTable"] =
$TYPE_PROPERTIES[ $OBJECT_TYPE[x] ]["RenderPath"] =

$OBJECT_ACTIONS[ $OBJECT_TYPE[x] ] = Array of actions ID's for Object x

$ACTION_PROPERTIES[ ActionID ]["RenderFile"] =
$ACTION_PROPERTIES[ ActionID ]["Name"] =
$ACTION_PROPERTIES[ ActionID ]["Desc"] = 
$ACTION_PROPERTIES[ ActionID ]["Image"] =

$OBJECT_PROPERTIES[ $OBJECT_TYPE[x] ] = Array of Property IDs for Object x

$PROPERTY_PROPERTIES[ PropertyID ]["Name"] =
$PROPERTY_PROPERTIES[ PropertyID ]["FieldMap"] =
$PROPERTY_PROPERTIES[ PropertyID ]["Type"] =

The SQL commands will be pretty easy.  I assume the difficult part is to
get Perl to build the file *shrug*?

OK - the query to build $OBJECT_TYPES and $TYPE_PROPERTIES would be:
select * from ObjectTypes;

Then just go through what's returned... 

To build $OBJECT_ACTIONS and $ACTION_PROPERTIES just do:
select * from ObjectActions;

You'll build $OBJECT_ACTIONS by referencing ActionID and ObjectType in the
records returned...

And you'll do the same for $OBJECT_PROPERTIES and $PROPERTY_PROPERTIES:
select * from ObjectProperties;

and do it just like the actions...

If this isn't clear in anyway - especially the variable structure... lets
talk...

This script would make my like SO much easier... and it would speed up the
system incredibly.  This one script will eliminate 3 to 5 DB queries on
EVERY page load.  Thats an incredible amount.  

So what are your thoughts on this?  Easy enough?  Comments and thoughts
welcome and urged!



-- 
Jason
http://vodka.linuxkb.org/~chardros