p2p.wrox.com Forums

Need to download code?

View our list of code downloads.

  Return to Index  

beginning_php thread: Dynamically generate classes

Message #1 by "Gerry Vandermaesen" <gerry.v@s...> on Thu, 19 Sep 2002 19:56:55 +0200
Hi all,
I'm not sure how to put my question, but I was wondering if it's
possible in PHP to dynamically generate classes. In particular I would
like to connect to a MySQL database, retreive all table names and create
classes using these names. For these classes I would like to dynamically
create properties and methods based on the fields of the table. For
class Table1 {
  var $field1;
  var $field2;
  function getField1 {
    return $this->field1;
  function getField2 {
    return $this->field2;
class Table2 {
  var $field3;
  var $field4;
  var $field5;
  function getField3 {
    return $this->field3;
  function getField4 {
    return $this->field4;
  function getField5 {
    return $this->field5;
Idea is to create a class which provides BASIC functionality of the
Torque layer for J2EE applications

  Return to Index