First of all, you're going to have an awfully slow site if you end up
calling mysql_connect as often as it looks like you will.

You really only want to call mysql_connect once per script...

Collections in PHP are handled with arrays.

http://php.net/array

--
WARNING [EMAIL PROTECTED] address is an endangered species -- Use
[EMAIL PROTECTED]
Wanna help me out?  Like Music?  Buy a CD: http://l-i-e.com/artists.htm
Volunteer a little time: http://chatmusic.com/volunteer.htm
----- Original Message -----
From: Mitja Pagon <[EMAIL PROTECTED]>
Newsgroups: php.general
To: <[EMAIL PROTECTED]>
Sent: Monday, September 10, 2001 3:36 PM
Subject: enumerations // collections


> I'm writting a class in PHP that has the following syntax
>
> <?
> require_once("consts.inc");
>
> class User {
>   var $ID;
>   var $name;
>   var $lastname;
>   var $username;
>   var $password;
>
>   function GetUser($ID) {
>    $db = mysql_connect(SQL_SERVER, SQL_USER, SQL_PASSWORD);
>    mysql_select_db(SQL_DATABASE, $db);
>
>    $RS = mysql_query("SELECT * FROM users WHERE ID=$ID", $db);
>
>    if ($fld = mysql_fetch_object($RS)) {
>     $this->ID = $fld->ID;
>     $this->name = $fld->name;
>     $this->lastname = $fld->lastname;
>     $this->username = $fld->username;
>     $this->password = $fld->password;
>     return true;
>    }
>    else {
>     return false;
>    } #end if
>
>    mysql_free_result($RS);
>    mysql_close($db);
>   }#end function
>
>
>   function AddUser() {
>    if ((empty($this->name)) or (empty($this->lastname)) or
> (empty($this->username)) or (empty($this->password))) {
>     return false;
>    }
>    else {
>     $db = mysql_connect(SQL_SERVER, SQL_USER, SQL_PASSWORD);
>     mysql_select_db(SQL_DATABASE, $db);
>     $SQL = "INSERT INTO users(name, lastname, username, password)
> VALUES('$this->name', '$this->lastname', '$this->username',
> '$this->password')";
>     mysql_query($SQL, $db);
>     return true;
>    } #end if
>
>   } #end function
>
>  } #end class
>
> ?>
>
> What I want to do now is implement a method(function) named ListUsers that
> will return all users from the database and asign the values to the
objects
> properties
>
> The result should be look something like this(at lest thats how
collections
> look like  in COM objects)
>
> $user->item[i]->property
>
> I hope I got my point accross.
>
> Thanks in advance!
>
> Mitja
>
>
>
>
>
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to