Create collections of objects

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

 



Hi people,

I want a class that allows create objects that get the information
consulting the DB. So, I am thinking to do something like this:

class element {
  public __construct($id,$type = 'id') {
    switch($type) {
    case 'id':
      $where = sprintf(" id = %d ",$id);
      break;
    case 'name':
      $where = sprintf(" name = %s ",escape($id));
      break;
      //...
      // get the row and call setName($row['name'])...
    }
  }
}

This works fine, but also I want a good way (efficient) of getting a
collection of these objects. I can't figure a convenient way. A static
function its a good posibility? I have some ideas but they imply public
setters of the class `element'.

Thanks for any help.

-- 

Emilio Astarita <emilio.astarita@xxxxxxxxx>

Gnus
http://gnus.org/
<http://www.gnu.org/philosophy/free-sw.html>

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux