For Programmers: Free Programming Magazines  


Home > Archive > PHP DB > June 2004 > Re: [PHP-DB] [slightly OT] OOP syntax









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: [PHP-DB] [slightly OT] OOP syntax
dpgirago@mdanderson.org

2004-06-30, 3:56 pm

Jeff,

From my recent readings, and others please correct me here, I think you
need to first declare the variables inside the Class, i.e., var
$srvr['etime'] = array();
var $srvr['etime']['server'];

-- then assign a value to them:

var $srvr['etime']['server'] = '27.22.1.5:1433';

In other words, these must be separate steps.

Not too sure about the syntax for declaring an array in the above. Maybe
this needs to be separate steps, too?

HTH,

dave


> I have some procedural code that i'm wanting to convert into classes(and
> i'm a bit greeen to OOP), hopefully to offer them to the PHP community.

I
> keep all my config data in arrays of arrays, which i'd like to keep when

i
> move to a class model, but can't seem to find out the correct defintion
> syntax.


> for example, here is a portion of the array storing connection info to a
> mssql db(keeping it in db land)
> $srvr['etime'] = array();
> $srvr['etime']['server'] = '27.22.1.5:1433';
> $srvr['etime']['db'] = 'dbmaster';
> $srvr['etime']['user'] = 'uname';
> $srvr['etime']['pass'] = 'pword';
> $srvr['etime']['title'] = 'eTime';
> $srvr['etime']['dfltch'] = 'N';
> $srvr['etime']['optional'] = false;


> How would this need to be defined at the top of a class to taken on as a
> class variable/array. Am i thinking of this wrong?


> I can add them all as scalar variables, but i'd rather work with arrays,

as
> i use the arrays to loop for other functions. I've tried a variety of
> syntaxes, but keep getting parse errors.


> thanks for any info you can provide.
> Jeff

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com