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

Re: Again - Perl: DB.PHP.Cache



On Tue, Nov 16, 1999 at 07:56:16PM -0800, Aaron Turner wrote:
> Quick Q (read below)

Long A (Read Below)

> On Tue, 16 Nov 1999, Jason Pincin wrote:
> 
> > 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 ...
> 
> Ok, I get this whole thing.  Question is what is the point of
> $OBJECT_TYPES if you can just iterate $TYPE_PROPERTIES to get the
> ObjectTypeId's-- seems a bit redundant to me.  Maybe I'm thinking too much
> Perl, but I assume that PHP can do that too.


Very correct you are - I could just itterate $TYPE_PROPERTIES.  I just
thought it'd be nice, in case I ever needed it... to have a sequential
list of Object Types to get me started.  If for some reason, we delete an
object type and ad a few more and move some things around, Object Types
ID's are going to get all out of order and might go like: 1, 6, 7, 8, 13,
14, 18

or sumthin like that.  The only way I'd be able to get them in that case
would be to itterate throut $TYPE_PROPERTIES with a "while (each())" and
examine the array keys do get the Object Types... very doable.  Not too
much difficulty.  But I figure, since we only have to do it once in the
script to get me a sequential list of them... why not?  That way I can go
through and pluck out my Type ID's in whatever way suits me best...
for-next's, while loops, etc.  

So yes, it is a little redundant - but it might make the object code a
little more readable in the future so I figured it'd be woth it.

Thoughts?

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