Re: [slightly OT] OOP syntax

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

 



VERY brief class introduction...

class database {
function database() { // function with the same name as class is the 'constructor'
$this->srvr = array(); // once you declare an array once, no need to declare 'sub' arrays
$this->srvr['etime']['server'] = '27.22.1.5:1433';
etc. etc.
}
}


$db = new database;
foreach ($db->srvr as $row) whatever..;

You will probably find as you learn more about classes that you end up doing whatever you are doing entirely differently.

Good luck.

At 04:20 AM 1/07/2004, you wrote:
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

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

. . Ross Honniball. JCU Bookshop Cairns, Qld, Australia. .

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux