/**
  * Constructor
  *
  * This shouldn't be called directly
  *
  * @see DatabaseObject::meta
  *
  * @param class string
  */
 function __construct($class)
 {
     $members = array();
     $refcls = new ReflectionClass($class);
     foreach ($refcls->getProperties() as $prop) {
         $name = $prop->getName();
         switch ($name) {
             case 'table':
             case 'key':
                 if (!$prop->isStatic() && Site::Site()->isDebugMode()) {
                     trigger_error("{$class}->{$name} should be {$class}::\${$name}");
                 }
                 $this->{$name} = $prop->getValue();
                 break;
             default:
                 if (!$prop->isStatic()) {
                     array_push($members, $name);
                 }
                 break;
         }
     }
     if (!isset($this->key)) {
         throw new RuntimeException("Cannot determine database key for {$class}");
     }
     parent::__construct($class, $members);
 }
 public function __construct($class)
 {
     $refcls = new ReflectionClass($class);
     $members = array();
     foreach ($refcls->getProperties() as $prop) {
         $name = $prop->getName();
         switch ($name) {
             case 'table':
             case 'FromClass':
             case 'ToClass':
             case 'LinkOrderClause':
             case 'AdditionalKey':
                 if (!$prop->isStatic() && Site::Site()->isDebugMode()) {
                     throw new RuntimeException("{$class}->{$name} should be {$class}::\${$name}");
                 }
                 $m = strtolower($name[0]) . substr($name, 1);
                 $v = $prop->getValue();
                 if ($name == 'FromClass' || $name == 'ToClass') {
                     if (!class_exists($v) || !is_subclass_of($v, 'DatabaseObject')) {
                         throw new RuntimeException("{$v} is not a DatabaseObject class");
                     }
                 }
                 $this->{$m} = $v;
                 break;
             default:
                 if (!$prop->isStatic()) {
                     array_push($members, $name);
                 }
                 break;
         }
     }
     if (!isset($this->fromClass)) {
         throw new RuntimeException("Cannot determine database fromClass for {$class}");
     }
     if (!isset($this->toClass)) {
         throw new RuntimeException("Cannot determine database toClass for {$class}");
     }
     parent::__construct($class, $members);
     $this->inspectColumn($this->getFromKey());
     $this->inspectColumn($this->getToKey());
     if (isset($this->additionalKey)) {
         $man = isset($this->manualColumns) ? $this->manualColumns : array();
         $this->manualColumns = array_unique(array_merge($man, $this->additionalKey));
         foreach ($this->additionalKey as $col) {
             $this->inspectColumn($col);
         }
     }
 }