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

Re: Again - Perl: DB.PHP.Cache



On Tue, Nov 16, 1999 at 09:46:03AM -0800, Aaron Turner wrote:
> Maybe I need another cup o' joe.  To make sure we're on the same page, can
> you maybe do a few example lines of output of the script based on the
> actual values of the DB?  Just so I can see what you want you want me to
> take and how to output it.  I think I get it, but I'd hate to find out
> that I'm doing it all wrong. :-)


Sure.  Lets take $OBJECT_TYPES and $TYPE_PROPERTIES

1) select * from ObjectTypes;
This returns a few records, lets take 2 of them:

ObjectTypeId | ObjectTypeName | ObjectTypeDesc | ValidChildren | etc...
             |                |                |               |
     1       |	KB Root       |  Root Cont ... |       3       | ...
     2       |  User Root     |  Root Cont ... |       4       | ...

2) Next step - create $OBJECT_TYPES which is just an array of valid Type
ID's:

$OBJECT_TYPES[0] = 1;
$OBJECT_TYPES[1] = 2;
...

3) Create $TYPE_PROPERTIES which will define everything else about an
ObjectType, and the key of the array will be equal to the ObjectTypeID:

$TYPE_PROPERTIES[1]["Name"] = "KB Root";
$TYPE_PROPERTIES[1]["Desc"] = "Root Cont...";
$TYPE_PROPERTIES[1]["ValidChildren"] = "3";
... etc for all properties of a type ...

$TYPE_PROPERTIES[2]["Name"] = "User Root";
$TYPE_PROPERTIES[2]["Desc"] = "Root Cont...";
$TYPE_PROPERTIES[2]["ValidChildren"] = "4";
... etc for all properties of a type ...


Now... lets do an example for $OBJECT_ACTIONS and $ACTION_PROPERTIES...

1) select * from ObjectActions; yields:

ActionID | ObjectType | ActionName    | ActionDesc | RenderFile         |
         |            |               |            |                    |
   6     |     1      | AdvancedSearch| ...        | kb/search.php3     |
   5     |     1      | SimpleSearch  | ...        | kb/search.php3     | 
   1     |     3      | SimpleSearch  | ...        | kb/search.php3     | 
   7     |     3      | SubmitArticle | ...        | kb/doc/submit.php3 |

2) build $OBJECT_ACTIONS

$OBJECT_ACTIONS[1][0] = 6;
$OBJECT_ACTIONS[1][1] = 5;
$OBJECT_ACTIONS[3][0] = 1;
$OBJECT_ACTIONS[3][1] = 7;

... etc ...

3) Build $ACTION_PROPERTIES

$ACTION_PROPERTIES[6]["Name"] = "AdvancedSearch";
$ACTION_PROPERTIES[6]["RenderFile"] = "kb/search.php3";
... etc for all properties ...
$ACTION_PROPERTIES[5]["Name"] = "SimpleSearch";
$ACTION_PROPERTIES[5]["RenderFile"] = "kb/search.php3";
...
$ACTION_PROPERTIES[1]["Name"] = "SimpleSearch";
$ACTION_PROPERTIES[1]["RenderFile"] = "kb/search.php3";
...
$ACTION_PROPERTIES[7]["Name"] = "SubmitArticle";
$ACTION_PROPERTIES[7]["RenderFile"] = "/kb/doc/submit.php3";
...


Is this a good enough example?  Let me know if you have any other
questions or are hazy on anything... 

J





> > $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
> > 
> 
> --
> Aaron Turner, Core Developer       http://vodka.linuxkb.org/~aturner/
> Linux Knowledge Base Organization  http://linuxkb.org/
> Because world domination requires quality open documentation.

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