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